Student Portfolio >> Index >> Coding >>JAVA Exercise 7
public class Manager extends Employee
{
private String title;
public Manager(String empName, double empSalary, int empHireYear, String emptitle ) // constructor with two parameters
{
name = empName;
salary = empSalary;
hireYear = empHireYear;
title = emptitle;
}
/* ======================================================================================
exercise changes GETTERS
====================================================================================== */
public String getTitle() // gets employee title
{
return title;
}
/* ======================================================================================
exercise changes SETTERS
====================================================================================== */
public void setTitle(String emptitle) // sets employee title
{
title= emptitle;
}
/* ======================================================================================
OVERLOAD raiseSalary
====================================================================================== */
public void raiseSalary(int Amount)
{
salary = salary + (Amount + 8000);
}
/* ======================================================================================
PRINT info on screen - override display() method in Employee
====================================================================================== */
public void display()
{
System.out.println( "Employee Title = " + title );
super.display();
}
}
<< Back Forward >> |
Copyright 2005 Kerstin Kegel