Kizspy.me
Question 2:
Question 2: (3 marks)
Write a class named Employee and a class named Developer extended from Employee (i.e. Employee
is a super class and Developer is a sub class) with the following information:
Employee
- salary: double
- experience: int
+ Employee()
+ Employee(salary: double,
experience: int)
+ getters & setters
+ calculateBonus(): double
Where:
Employee()
default constructor that initializes
salary and experience to 0.
Employee(salary: double, experience: int)
parameterized constructor, which sets values to
salary, and experience.

getters & setters: write the setters and getters all
of the fields.

calculateBonus(): double returns the bonus
based on experience years, with bonus = salary*
(experience * 0.05)
Zoom
-projects: int
+ Developer()
Developer
+ Developer(salary: double,
experience: int, projects: int)
+ getters & setters
+ toString(): String
+ getLevel(): String
Where:
• Developer() - Default constructor, calls the parent class
constructor and sets projects to 0
• Developer(salary: double, experience: int, projects:
int) - parameterized constructor, which sets values to
salary, experience, projects.

getters & setters: write the setters and getters all of the
fields.
+100%
Close