Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1.  
  2. package flexitime;
  3. /*
  4. * @author Adrian Smith
  5. */
  6. import java.util.ArrayList;
  7.  
  8.  
  9. public class StaffRecord extends StaffData {
  10. /*
  11. * import FlexiWeek arrays into a array list
  12. * put manager object into line manager
  13. */
  14. private ArrayList<FlexiWeek> flexi;
  15. private double flexiBalance;
  16. private Manager lineManager;
  17.  
  18. /* parameterised constructor
  19. * using variables from staff data and this class
  20. */
  21.  
  22. public StaffRecord(String firstName, String lastName, String dept, Manager lineManager) {
  23. super(firstName, lastName, dept);
  24. this.flexi = new ArrayList<FlexiWeek>();
  25. this.flexiBalance = 0;
  26. this.lineManager = lineManager;
  27. this.lineManager.addStaffMember(this);
  28. }
  29. /*
  30. * @parma lineManager null lineManager
  31. */
  32. public StaffRecord() {
  33. super();
  34. this.lineManager = null;
  35. }
  36. /*
  37. * @return flexiBalance get method for flexiBalance
  38. */
  39.  
  40. public double getFlexiBalance() {
  41. return flexiBalance;
  42. }
  43.  
  44. /*
  45. * @return lineManager get method for LineManager
  46. */
  47.  
  48. public Manager getLineManager() {
  49. return lineManager;
  50. }
  51. /*
  52.  
  53. * @return return false if flexiBalance is over 40 else return true
  54. *
  55. */
  56.  
  57. public boolean addWeek(FlexiWeek newWeek) {
  58. this.flexi.add(newWeek);
  59. double Temp = 0;
  60.  
  61. for (FlexiWeek flexiWeek : flexi) {
  62. Temp += flexiWeek.getWeekHours() - (double) 35;
  63. }
  64. if (Temp > 40) {
  65. flexiBalance = 40;
  66. return false;
  67. } else {
  68. flexiBalance = Temp;
  69. return true;
  70. }
  71. }
  72. /*
  73. * @return return the correct status code based on the value of flexiBalance
  74. */
  75. public int getStatus() {
  76. if (this.flexiBalance >= 40) {
  77. return 2;
  78. } else if (this.flexiBalance >= 35) {
  79. return 1;
  80. } else if (this.flexiBalance <= -15) {
  81. return 4;
  82. } else if (this.flexiBalance <= -10) {
  83. return 3;
  84. } else {
  85. return 0;
  86. }
  87. }
  88.  
  89. /*
  90. * @param flexiBalance variable for flexi time amount reset to 0 in this method
  91. */
  92. public void resetBalance() {
  93. flexiBalance = 0;
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement