Results 1 to 16 of 16
  1. #1
    CS Geek is offline Member
    Join Date
    Aug 2008
    Posts
    11
    Rep Power
    0

    Question how to write this class?

    Hi there

    I have asked to write a class which called "Worker" which contain methods and fields related to the following requrirements:

    - A worker should have a number allocated sequentially starting from 122.
    - the class should know the number of tasks required and whether Morning or evening, in first floor or in second floor, require wearing a uniform or not.
    - if the task has allocated to another worker, it should know who is that worker and how much does he take for this work.

    I think it does need another class, for examlpe (AnotherWorker). :rolleyes:


    Can you help me.. just tell me what should I use of methods and fields... tell me as possible as you can.

  2. #2
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    You should really give your first attempt we are not here to write code for you


    that is just plain lazy.....


    substantiate your request with the code you have started

    you will never understand Java if you don't try
    Last edited by aaroncarpet; 11-16-2009 at 07:29 AM. Reason: other thoughts

  3. #3
    CS Geek is offline Member
    Join Date
    Aug 2008
    Posts
    11
    Rep Power
    0

    Default

    Yeah I know that, but I just want you to give me idea not how to write the source code, but about what should it contain. For example, you can tell me you should have three fields one for... and one for.. and the last one for... Also you should have a mthod which does... etc

    I hope this helps. :D

  4. #4
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default i don't even know if you know java

    submit your initial code.....or what you think it should be....copy and pasting won't make you a programmer

  5. #5
    CS Geek is offline Member
    Join Date
    Aug 2008
    Posts
    11
    Rep Power
    0

    Default

    immmm, to start with it can be like:


    Java Code:
    public class Worker
    {
    private startNumber;
    private numberOfTasks;
    private duration;
    
    
    public Worker(int no,)
    {
    startNumber= 122;
    no = numberOfTasks;
    duration="";
    }
    
    public void morning()
    {
    duration="Morining";
    }
    
    public void evening()
    {
    duration="Evening";
    }
    
    
    //.....
    
    }

    but I think it will be better instead of make it full of methods, how I can manage to put choices and the user can choose from them!

  6. #6
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    now I am pissed and I am going to give you the code and you will have learned nothing
    Java Code:
    private class worker extends administrater implements ignorant_people throws Exception
          {static int wrkr_num;
    
           int num_of_tasks;
           String morniing, evening;
    
    worker (){wrkr_num=122;}
    
        public int  inquire_number_of_tasks (){ return administrater.getTaskNumber();}
        public boolean workergender(wkr_num){ if (wrkr_num.gender ==female) }throw gender.not.male exception
    Last edited by aaroncarpet; 11-16-2009 at 07:58 AM.

  7. #7
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    i can be vague too with code you dont understand

  8. #8
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    you need to name your data intuitively
    start number? how about initial_employee_number

  9. #9
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    public Worker(int no,) YOUR CLASS IS NAMED WORKER THIS IS YOUR CONSTRUCTOR
    { THERE IS NOTHING BEHIND THAT COMMA...


    number of tasks is private but is it an integer, long, float, double????
    startNumber= 122;
    no = numberOfTasks;
    duration="";
    }
    Last edited by aaroncarpet; 11-16-2009 at 08:14 AM. Reason: all of your declarations are missing the primitive data types

  10. #10
    CS Geek is offline Member
    Join Date
    Aug 2008
    Posts
    11
    Rep Power
    0

    Default

    but how the user will select choices between (morning, or evening)? first floor or second floor?

  11. #11
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    I am going to give you alot of help and modify the code you posted
    Java Code:
    public class Worker
    {
    private int startNumber; // should be a more intuitive name like first employee
    private int numberOfTasks;
    private String duration;
    
    //this is your constructor you cant even comprehend passing variables to it 
    Worker()
    {
    startNumber= 122;
    no = numberOfTasks;//who determines the number of tasks
    duration="";//duration = a blank string now
    }
    
    public void morning()
    {
    duration="Morining";
    }
    
    public void evening()
    {
    duration="Evening";
    }
    
    
    //.....
    
    }// where is your main method????????????????
    Last edited by aaroncarpet; 11-16-2009 at 08:23 AM. Reason: forum etiquette

  12. #12
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    that is determined by their schedule the user unless the user is the employer cant decide that

  13. #13
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    you dont even know how to compile code nor have the j2se installed on your system or a third party editor like textpad or a fully lloaded ide like netbeans. compile a hello program on your computer and come back here

  14. #14
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    you don't even know how to declare variables.....you should lay off the pipe

  15. #15
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    how will your program open without a main go read

  16. #16
    CS Geek is offline Member
    Join Date
    Aug 2008
    Posts
    11
    Rep Power
    0

Similar Threads

  1. How to write an app that reverses
    By CaseyRenee87 in forum New To Java
    Replies: 3
    Last Post: 08-18-2009, 02:48 AM
  2. Using Scanner class to write to Vectors
    By JonoF in forum New To Java
    Replies: 16
    Last Post: 04-16-2009, 03:46 AM
  3. How to Write this if statement?
    By PeterFeng in forum New To Java
    Replies: 1
    Last Post: 01-14-2009, 07:11 AM
  4. How to write....**
    By krichait in forum New To Java
    Replies: 9
    Last Post: 08-07-2008, 02:09 PM
  5. Replies: 0
    Last Post: 04-06-2008, 07:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •