Q1_20250829091136.webp
Jellal87

Q1_20250829091136.webp

  • Media owner Jellal87
  • Ngày thêm
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
Chưa có bình luận nào.

Thông tin

Category
PRO192
Thêm bởi
Jellal87
Ngày thêm
Lượt xem
4,898
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom