• Post Reply Bookmark Topic Watch Topic
  • New Topic

Payroll java project  RSS feed

 
Alex Breault
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am working on a Payroll project (Payroll.java and PayrollApp.java) and have almost everything except for two things:
1) Once all employees are entered, the user is prompted to enter an iD number, then if found delete if from the arraylist all of the payrolls are stored in. (Lines 115-125 of PayrollApp)
2) When displaying the arraylist, it displays the amount of times the length is (For example, if containing two payroll objects, it will display twice. And three times if length is 3) How can i get it to display only once? (without brackets and commas preferably) (Lines 100-105; 198-203 of PayrollApp)
Thank you to anyone that helps!
Here's my code: (I am not sure if you needed it all of just the lines I mentioned previously so I included everything)

 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alex Breault wrote:Hello, I am working on a Payroll project (Payroll.java and PayrollApp.java) and have almost everything except for two things:
1) Once all employees are entered, the user is prompted to enter an iD number, then if found delete if from the arraylist all of the payrolls are stored in. (Lines 115-125 of PayrollApp)
2) When displaying the arraylist, it displays the amount of times the length is (For example, if containing two payroll objects, it will display twice. And three times if length is 3) How can i get it to display only once? (without brackets and commas preferably) (Lines 100-105; 198-203 of PayrollApp)


Point 1: you currently have Map<Integer, Payroll>. If you need to delete the employee ID (the Integer) and "all" its payroll why not use Map<Integer, List<Payroll>>

Point 2: Looping a list and showing its content one by one is normal behavior. Why do you need to show only one? If indeed only one, which payroll to show, latest one?
 
Campbell Ritchie
Marshal
Posts: 56533
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried this?
if (myMap.containsKey("123456")) ...
Your main method is much much too long. The ideal length for a main method is one statement; you have all sorts of things in there which should be separate methods.
Never use == false or == true.
If you need to test whether a boolean is false use !b.
 
Alex Breault
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the displaying of the Arraylist, I need the entire list to be displayed only once whenever I display it, without the brackets and commas.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!