Advertisement
SMF

Project 3 Phase 1

SMF
Oct 17th, 2013
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package project.pkg3;
  6.  
  7. /**
  8. *
  9. * @author jhaupt
  10. */
  11. public class Employee {
  12. private int id;
  13. private String name;
  14. private String position;
  15. private int yearsOfService;
  16. private String allowanceType;
  17. private int allowanceAmount;
  18.  
  19. public Employee() {}
  20.  
  21. public Employee(int id, String name, String position, int yearsOfService, String allowanceType, int allowanceAmount)
  22. {
  23. this.id = id;
  24. this.name = name;
  25. this.position = position;
  26. this.yearsOfService = yearsOfService;
  27. this.allowanceType = allowanceType;
  28. this.allowanceAmount = allowanceAmount;
  29. }
  30.  
  31. public void setAllowance(int newAllowanceAmount)
  32. {
  33. allowanceAmount = newAllowanceAmount;
  34. }
  35.  
  36. public void changeAllowance(String newAllowanceType, int newAllowanceAmount)
  37. {
  38. allowanceType = newAllowanceType;
  39. allowanceAmount = newAllowanceAmount;
  40. }
  41.  
  42. public double calculateSalary()
  43. {
  44. double salary = 5432.0 * ( 1 + yearsOfService / 100 );
  45. return salary;
  46. }
  47.  
  48. public double getSalary()
  49. {
  50. return calculateSalary();
  51. }
  52.  
  53. public void showEmployee()
  54. {
  55. //System.out.printf("%-16s%1d%\t\t\t%s%\t%s\t%s%\t%f%\t\t%s%\t%d%\t%s", "Employee #" + id, "- NAME:", name, "POSITION:", position, "SALARY:", getSalary(), "ALLOWANCE", allowanceAmount, allowanceType); //makes head spin
  56. System.out.printf("%-1s%-1d%-13s%-24s%-1s\t%s\t%s%-1s", "Employee #", id, " - NAME:", name, ",", "POSITION:", position, "," );
  57. //System.out.println("Employee #" + id + "- NAME:" + "\t\t" + name + "\t" + "POSITION: " + position + "SALARY: " + getSalary() + "\t\t" + "ALLOWANCE: " + allowanceAmount + " " + allowanceType); //works but not formated correctly
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement