I have been learning java in college for about 6 weeks now, our latest assignment seems overly complicated so I was wondering if anyone could help me out.
https://www.dropbox.com/s/rv20cm39si...n%202%29_2.pdf
This is my code so far, any help on any of the further parts which I have not completed yet would be greatly appreciated
Oh and just so you know we are using bluej.
Employee Class
public class Employee { private int employeeNumber; private String employeeName; private String employeeAddress; private double annualIncome; private int taxCategory; private Department dept; /** * Constructor for objects of class Employee */ public Employee(int employeeNumber, String employeeName, String employeeAddress, double anualIncome, int taxCategory, Department dept) { if((employeeNumber >= 1000) && (employeeNumber <= 9999)) { this.employeeNumber = employeeNumber; } else { System.out.println("EmployeeNumber can only be 4 characters long"); this.employeeNumber = 1000000; //default value } if(employeeName.length() <= 20) { this.employeeName = employeeName; } else { System.out.println("employeeName cannot be more than 2 characters"); this.employeeName = "Not Set"; //Default Input } this.employeeAddress = employeeAddress; if(annualIncome >= 0) { this.annualIncome = annualIncome; } else { System.out.println("AnnualIncome must be non-negative"); this.annualIncome = 0; //Default Value } if((taxCategory > 0) && (taxCategory < 3)) { this.taxCategory = taxCategory; } else { System.out.println("There are only two valid values 1 = Single or 2 = Married on one income"); this.taxCategory = 1; //Default Value } } public int getEmployeeNumber() { return employeeNumber; } public String getEmployeeName() { return employeeName; } public String getEmployeeAddress() { return employeeAddress; } public double getAnnualIncome() { return annualIncome; } public int getTaxCategory() { return taxCategory; } public void setEmployeeNumber(int employeeNumber) { if((employeeNumber >= 1000) && (employeeNumber <= 9999)) { this.employeeNumber = employeeNumber; } else { System.out.println("employeeNumber Should be no more than 4 digits"); } } public void setEmployeeName(String employeeName) { if(employeeName.length() <= 20) { this.employeeName = employeeName; } else { System.out.println("employeeName must be no more than 20 characters"); } } public void setEmployeeAddress(String employeeAddress) { this.employeeAddress = employeeAddress; } public void setAnnualIncome(double annualIncome) { if(annualIncome >= 0) { this.annualIncome = annualIncome; } else { System.out.println("annualIncome must be non-negative"); } } public void setTaxCategory(int taxCategory) { if((taxCategory > 0) && (taxCategory < 3)) { this.taxCategory = taxCategory; } } public double calculateAnnualTax() { if(taxCategory == 1) { if(annualIncome <= 32000) { } } else if(taxCategory == 2) { } } }
Department Class
public class Department { private String deptName; private String deptHead; private String deptAdministrator; /** * Constructor for objects of class Department */ public Department(String deptName, String deptHead, String deptAdministrator) { if(deptName.length() <= 30) { this.deptName = deptName; } else { System.out.println("deptName should eb no more than 30 characters long"); this.deptName = "default"; //defaultValue } if(deptHead.length() <= 20) { this.deptHead = deptHead; } else { System.out.println("deptHead should be no longer than 20 characters long"); this.deptHead = "default"; //defaultValue } if(deptAdministrator.length() <= 20) { this.deptAdministrator = deptAdministrator; } else { System.out.println("deptAdministrator should be no longer than 20 characters"); } } public String getDeptName() { return deptName; } public String getDeptHead() { return deptHead; } public String getDeptAdministrator() { return deptAdministrator; } public void setDeptName(String deptName) { if(deptName.length() <= 30) { this.deptName = deptName; } else { System.out.println("deptName should be no more than 30 characters long"); } } public void setDeptHead(String deptHead) { if(deptHead.length() <= 20) { this.deptHead = deptHead; } else { System.out.println("deptHeadmust should be no more than 20 charcters"); } } public void setDeptAdministrator(String deptAdministrator) { if(deptAdministrator.length() <= 20) { this.deptAdministrator = deptAdministrator; } else { System.out.println("deptAdministrator should be no more than 20 characters"); } } }