We are given the following tasks and I wonder how to do this...
TASK A:
After review with management, it is decided that we will store the following information for each employee: • employee ID (an integral number, automatically assigned when a new employee is added) • first name and last name • department number (an integral value, call it dept) • pay rate (a floating-point value, using a double) In addition, we would like: • a method called getPayInfo() that will return a sentence with the employee's name, id, department, and check amount • a method called getFullName() that will return the first and last names separated by a space 1. Define a class called Employee with these characteristics, using standard practices for limiting data access and for method naming 2. In order to be useful, there should be methods to set and get all properties (except setting the employee id, which will happen automatically in a manner to be determined later; for now, just let it default to 0) 3. Create a class called Payroll with a main method, it should: o instantiate an Employee object o set values for all properties o call the getPayInfo() method to see the results TASK B: 1. Modify your Employee class to use a constructor that accepts parameters for the first and last names, department, and pay rate 2. In Payroll, modify main to add another Employee variable that receives an instance created using this constructor 3. Also add a constructor that takes no parameters and does nothing (as we discussed above) public Employee() { } TASK C: 1. Add more Employee constructors: o one that takes values for first and last names only o one that takes values for first name, last name, and department o one that takes values for first name, last name, and pay rate o note that, in practice, you can use the parameter lists for constructors to help enforce what you would consider valid combinations of properties - for example, if you would not want an employee to exist in a state where they had name and department information, but no pay rate, then the absence of that particular constructor would help ensure that o judicious use of copy-paste-edit can speed up this process, but be careful to make every necessary edit if you do this! 2. Create and pay additional instances using these constructors 3. You will find yourself writing somewhat repetitive code, setting the same values the same way in several different constructors - we will address this in a few pages TASK D: 1. Now we can clean up our Employee class definition 2. Modify the set methods to use the same name for each parameter as the associated property 3. Modify the constructors to eliminate redundant code - for example: public Employee(String firstName, String lastName, int dept) { this(firstName, lastName); setDept(dept); } TASK E: 1. Add a private and static integer property called nextId to the Employee class (give it an initial value of 1) 2. Modify the declaration of the id property as follows: private int id = nextId++; 3. What happens when each new Employee gets instantiated? TASK F: 1. Create a package called employees; put the Employee class into this package (leave Payroll where it is) 2. This will require not only creating the directory and moving the file, but also adding an import statement to Payroll and a package statement to Employee 3. To compile, start in the project root directory (the directory containing Payroll). If you compile Payroll as usual, it will also find and compile Employee. To compile just Employee, you would still work in the project root directory, but execute javac employees\Employee.java 4. Run Payroll in the usual fashion I have already working with this but i can't finish it in my own... |
Re:
If I were you I'd post this question on http://www.codeproject.com/
That's the crowd you want to talk to |
I don't think I've ever seen such a blatant "Do my homework for me" post.
|
sorry,,
Quote:
|
Quote:
PS 1) I've once helped somebody with his homework and as a result he failed because the code that he handed in was too advanced for the level. 2) There is a programming section here at LQ |
Per the LQ Rules, please do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and Google searches) and we'll do our best to help. Also, keep in mind that your instructor might also be an LQ member.
In other words, show us your work and ask specific questions. |
Quote:
If this is for you at your place of employment, you're getting paid to do this work. If you "really need help", again, POST WHAT YOU'VE WRITTEN and we can help you. Otherwise, do the job you were hired to do, or tell your boss you're in over your head. |
Quote:
It is from this online Java lesson http://www.learn-java-tutorial.com/J...jects.cfm#h1.3 I don't care to guess whether the OP is using that lesson directly or whether his instructor either copied from there or maybe is the original author of the lesson and using it in more than one place. Quote:
If you were already using that online lesson, tell us which specific details you don't understand. |
Everyone Chill!! .....:)
If this follows the typical homework pattern, OP is not listening and will not be back. A WEE bit off-topic: I would love to find a fair and yet effective to curtail the more egregious homework posts---the ideas should go in LQ suggestions and feedback |
Quote:
Thanks for "egregious" -- le bon mot and appositely applied! :) |
And thank YOU for "appositely".....:)
And now we will close this masterpiece----colan1838 is invited to start a new thread which follows the homework guidelines so eloquently and appositely elucidated herein......:) |
All times are GMT -5. The time now is 10:42 PM. |