Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SalariedEmployee extends Employee
- {
- private double salary;
- public SalariedEmployee()
- {
- super();
- salary = 0;
- }
- public SalariedEmployee(String theName, Date theDate, double theSalary)
- {
- super(theName, theDate);
- if(theSalary >= 0)
- salary = theSalary;
- else
- {
- System.out.println("Fatal Error: Negative slary.");
- System.exit(0);
- }
- }
- public SalariedEmployee(SalariedEmployee originalObject)
- {
- super(originalObject);
- salary = originalObject.salary;
- }
- public double getSalary()
- {
- return salary;
- }
- public double getPay()
- {
- return salary/12;
- }
- public void setSalary(double newSalary)
- {
- if(newSalary >= 0)
- salary = newSalary;
- else
- {
- System.out.println("Fatal Error: Negative Salary.");
- System.exit(0);
- }
- }
- public String toString()
- {
- return (getName() + " " + getHireDate().toString() + "\n$" + salary + " per year");
- }
- public boolean equals(SalariedEmployee other)
- {
- return(getName().equals(other.getName()) && getHireDate().equals(other.getHireDate())
- && salary == other.salary);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement