Results 1 to 16 of 16
Thread: how to write this class?
- 11-16-2009, 07:18 AM #1
Member
- Join Date
- Aug 2008
- Posts
- 11
- Rep Power
- 0
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.
- 11-16-2009, 07:24 AM #2
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 tryLast edited by aaroncarpet; 11-16-2009 at 07:29 AM. Reason: other thoughts
- 11-16-2009, 07:31 AM #3
Member
- Join Date
- Aug 2008
- Posts
- 11
- Rep Power
- 0
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
- 11-16-2009, 07:33 AM #4
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
- 11-16-2009, 07:46 AM #5
Member
- Join Date
- Aug 2008
- Posts
- 11
- Rep Power
- 0
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!
- 11-16-2009, 07:54 AM #6
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 exceptionLast edited by aaroncarpet; 11-16-2009 at 07:58 AM.
- 11-16-2009, 08:02 AM #7
i can be vague too with code you dont understand
- 11-16-2009, 08:04 AM #8
you need to name your data intuitively
start number? how about initial_employee_number
- 11-16-2009, 08:11 AM #9
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
- 11-16-2009, 08:14 AM #10
Member
- Join Date
- Aug 2008
- Posts
- 11
- Rep Power
- 0
but how the user will select choices between (morning, or evening)? first floor or second floor?
- 11-16-2009, 08:22 AM #11
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
- 11-16-2009, 08:25 AM #12
that is determined by their schedule the user unless the user is the employer cant decide that
- 11-16-2009, 08:31 AM #13
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
- 11-16-2009, 08:35 AM #14
you don't even know how to declare variables.....you should lay off the pipe
- 11-16-2009, 08:37 AM #15
how will your program open without a main go read
- 11-16-2009, 07:36 PM #16
Member
- Join Date
- Aug 2008
- Posts
- 11
- Rep Power
- 0
Similar Threads
-
How to write an app that reverses
By CaseyRenee87 in forum New To JavaReplies: 3Last Post: 08-18-2009, 02:48 AM -
Using Scanner class to write to Vectors
By JonoF in forum New To JavaReplies: 16Last Post: 04-16-2009, 03:46 AM -
How to write a java bean class object to XML file
By Java Tip in forum java.ioReplies: 1Last Post: 01-29-2009, 09:35 AM -
How to Write this if statement?
By PeterFeng in forum New To JavaReplies: 1Last Post: 01-14-2009, 07:11 AM -
How to write....**
By krichait in forum New To JavaReplies: 9Last Post: 08-07-2008, 02:09 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks