Pre-Lab_REVISION JAVA AND OOP
Pre-Lab_REVISION JAVA AND OOP
Superclass : Square
Attributes :
double height; //height of a square
double width; //width of a square
double surfaceArea;//the surfaceArea calculate for a square
Methods :-
double computeSurfaceArea();
// calculate the surface area of a square
// (height * width) and return the value
Subclass : Cube
Attributes :
double depth; //depth of a cube
Methods :-
double computeSurfaceArea();
// calculate the surface area of a cube
// (surfacearea of square * depth) and return the value.
Given the following classes and inheritance hierarchy which are used to store various types of
CUSTOMERS for Indah Raya Beauty Spa:
CUSTOMER
VIP REGULAR
The class CUSTOMER has three fields: name, customerCat (VIP/REGULAR) and member with
boolean type. Jjjjjjjj888888VIP class is inherited from class CUSTOMER. Its new attribute is
price and vipService (Scrubs & wraps (S)/ Body Massages(B)). Meanwhile, REGULAR class also
inherited from class Customer and has three fields: price & regularService(Body Massages(B)/
Facial(F))and newPrice. Two of subclasses have a function display () to display all info.
a) Define the constructor and getters for superclass CUSTOMER and its subclasses VIP and
REGULAR.
b) VIP subclass has a method named calcNewPrice() which returns new price after discount for
the service at this spa.REGULAR class has a method calcService() to calculate the price should
customer pay after discount.
c) Write the method calcNewPrice() for the VIP and calcService() for REGULAR based on table
above.If the customer is the member at spa, member’s price will be deducted from the price
after discount.
d) Apply Polymorphism concept. Write an application program for the following Task: -
• To declare an array of object for Customer which have 10 elements
• Input all the info needed. Mix all customer type (VIP/REGULAR)
• Count number of VIP customers come to Spa.
• Calculate company total income from both customer types.
• Count the number of REGULAR customers who are booking body massage and display
the information customer in detail.