LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 10-15-2009, 08:51 AM   #1
colan1838
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Rep: Reputation: 0
Smile 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...
 
Old 10-15-2009, 09:15 AM   #2
threelions66
LQ Newbie
 
Registered: Aug 2006
Location: Chicago
Distribution: Debian
Posts: 11

Rep: Reputation: 0
Re:

If I were you I'd post this question on http://www.codeproject.com/
That's the crowd you want to talk to
 
Old 10-15-2009, 09:19 AM   #3
Lordandmaker
Member
 
Registered: Sep 2005
Location: London, UK
Distribution: Debian
Posts: 258

Rep: Reputation: 38
I don't think I've ever seen such a blatant "Do my homework for me" post.
 
Old 10-15-2009, 09:56 AM   #4
colan1838
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Original Poster
Rep: Reputation: 0
sorry,,

Quote:
Originally Posted by Lordandmaker View Post
I don't think I've ever seen such a blatant "Do my homework for me" post.
But I really need help regarding with this matter. Infact while i'm waiting for any reply I am also doing the tasks. Yet i'mnot still finish.
 
Old 10-15-2009, 10:02 AM   #5
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally Posted by colan1838 View Post
...

I have already working with this but i can't finish it in my own...
OK, so tell us with what you're stuck and show us the code that you've written till now.

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
 
Old 10-15-2009, 10:08 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
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.
 
Old 10-15-2009, 10:39 AM   #7
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,921

Rep: Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690
Quote:
Originally Posted by colan1838 View Post
But I really need help regarding with this matter. Infact while i'm waiting for any reply I am also doing the tasks. Yet i'mnot still finish.
Well if this is homework, and you say you're working on it, post what you've written and where you're having a problem, and we'll be glad to help you.

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.
 
Old 10-15-2009, 12:51 PM   #8
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181
Quote:
Originally Posted by TB0ne View Post
If this is for you at your place of employment
Don't be absurd.

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:
Originally Posted by colan1838 View Post
I have already working with this but i can't finish it in my own...
If you are learning Java in a classroom and didn't have the above link to the online version, you apparently missed some things in class (or you would be able to do this easy assignment). Try reading the online version of the lesson to fill in the gaps for whatever you missed in class.

If you were already using that online lesson, tell us which specific details you don't understand.

Last edited by johnsfine; 10-15-2009 at 01:01 PM.
 
Old 10-15-2009, 01:58 PM   #9
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
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
 
Old 10-15-2009, 02:06 PM   #10
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by pixellany View Post
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
OK -- chilled!

Thanks for "egregious" -- le bon mot and appositely applied!
 
Old 10-15-2009, 02:21 PM   #11
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
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......
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What are zombie tasks? centosfan Linux - General 7 09-22-2008 08:20 AM
<Defunct> in Tasks cb951303 Slackware 1 02-24-2004 12:56 PM
cron tasks MaverickApollo Linux - Software 1 02-02-2004 02:06 PM
suspending tasks ??? flynnhandley Linux - Software 2 10-02-2003 12:32 AM
Need some tasks AMDPwred Linux - General 5 02-28-2003 04:22 PM


All times are GMT -5. The time now is 10:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration