Professional Documents
Culture Documents
Inheritance Polymorph Is M Dec 2019
Inheritance Polymorph Is M Dec 2019
Inheritance Polymorph Is M Dec 2019
Uptown Steamboat & Grill is a popular restaurant in Penang. It offers two (2) options to
customers whether they like to dine-in or delivery. Given the following
SteamboatGrill, Dine_In and Delivery classes:
i. Declare an array named dine to store 50 dine-in information and another array
named deliver to store 50 delivery information.
(1 mark)
ii. Display the dine-in information and the total price that should be paid by customer
who is a member of that restaurant.
(3 marks)
iii. Count and display the number of deliveries with add-on drinks.
(3 marks)
QUESTION 4
//normal constructor
//accesor methods: getGrade(), getSubject()
//toString()
//definition of abstract method
}
public class KindergartenTeacher extends Teacher
{
int OTHours; //overtime hours per month
//normal constructor
//accessor method: getOT()
//toString()
//definition of abstract method
}
The salary of school teacher is calculated based on the grade as shown in Table 1:
Each overtime hour will be paid RM10. The salary for the kindergarten teacher is the
total of basic salary and overtime hours pay.
(6 marks)
b) Write code fragment for the following questions using the polymorphism concept:
ii. Display the teacher name and the salary obtained by English teacher whose
grade is DG48.
(4 marks)
iii. Calculate and display the total overtime hours done by the kindergarten teachers.
(4 marks)