Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package flexitime;
- /*
- * @author Adrian Smith
- */
- import java.util.ArrayList;
- public class StaffRecord extends StaffData {
- /*
- * import FlexiWeek arrays into a array list
- * put manager object into line manager
- */
- private ArrayList<FlexiWeek> flexi;
- private double flexiBalance;
- private Manager lineManager;
- /* parameterised constructor
- * using variables from staff data and this class
- */
- public StaffRecord(String firstName, String lastName, String dept, Manager lineManager) {
- super(firstName, lastName, dept);
- this.flexi = new ArrayList<FlexiWeek>();
- this.flexiBalance = 0;
- this.lineManager = lineManager;
- this.lineManager.addStaffMember(this);
- }
- /*
- * @parma lineManager null lineManager
- */
- public StaffRecord() {
- super();
- this.lineManager = null;
- }
- /*
- * @return flexiBalance get method for flexiBalance
- */
- public double getFlexiBalance() {
- return flexiBalance;
- }
- /*
- * @return lineManager get method for LineManager
- */
- public Manager getLineManager() {
- return lineManager;
- }
- /*
- * @return return false if flexiBalance is over 40 else return true
- *
- */
- public boolean addWeek(FlexiWeek newWeek) {
- this.flexi.add(newWeek);
- double Temp = 0;
- for (FlexiWeek flexiWeek : flexi) {
- Temp += flexiWeek.getWeekHours() - (double) 35;
- }
- if (Temp > 40) {
- flexiBalance = 40;
- return false;
- } else {
- flexiBalance = Temp;
- return true;
- }
- }
- /*
- * @return return the correct status code based on the value of flexiBalance
- */
- public int getStatus() {
- if (this.flexiBalance >= 40) {
- return 2;
- } else if (this.flexiBalance >= 35) {
- return 1;
- } else if (this.flexiBalance <= -15) {
- return 4;
- } else if (this.flexiBalance <= -10) {
- return 3;
- } else {
- return 0;
- }
- }
- /*
- * @param flexiBalance variable for flexi time amount reset to 0 in this method
- */
- public void resetBalance() {
- flexiBalance = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement