Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package project.pkg3;
- /**
- *
- * @author jhaupt
- */
- public class Employee {
- private int id;
- private String name;
- private String position;
- private int yearsOfService;
- private String allowanceType;
- private int allowanceAmount;
- public Employee() {}
- public Employee(int id, String name, String position, int yearsOfService, String allowanceType, int allowanceAmount)
- {
- this.id = id;
- this.name = name;
- this.position = position;
- this.yearsOfService = yearsOfService;
- this.allowanceType = allowanceType;
- this.allowanceAmount = allowanceAmount;
- }
- public void setAllowance(int newAllowanceAmount)
- {
- allowanceAmount = newAllowanceAmount;
- }
- public void changeAllowance(String newAllowanceType, int newAllowanceAmount)
- {
- allowanceType = newAllowanceType;
- allowanceAmount = newAllowanceAmount;
- }
- public double calculateSalary()
- {
- double salary = 5432.0 * ( 1 + yearsOfService / 100 );
- return salary;
- }
- public double getSalary()
- {
- return calculateSalary();
- }
- public void showEmployee()
- {
- //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
- System.out.printf("%-1s%-1d%-13s%-24s%-1s\t%s\t%s%-1s", "Employee #", id, " - NAME:", name, ",", "POSITION:", position, "," );
- //System.out.println("Employee #" + id + "- NAME:" + "\t\t" + name + "\t" + "POSITION: " + position + "SALARY: " + getSalary() + "\t\t" + "ALLOWANCE: " + allowanceAmount + " " + allowanceType); //works but not formated correctly
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement