CSC186 Lab Assignment 6 – Inheritance solution

$25.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

1.1 Given the following superclass named Food and subclass named WesternFood.
a) Complete the above classes by considering the following methods:
i. Write the default and normal constructor methods.
ii. Write the mutator methods for each attribute.
iii. The accessor methods for each attribute

iv. Write the printer method to return object information.
v. Write the processor methods named Payment() which calculates and returns the
amount to be paid by the customer based on the following table:
Set Set Description Amount (RM)
1 Lamb Chop 30.00
2 Chicken Chop 20.00
3 Fish and Chip 15.00
Super Class : Food
Attributes : String name; // customer’s name
int quantityOfOrder; //quantity order made
boolean member; //true – if member, otherwise
//false
Methods : Constructor, mutator, retriever, printer
Sub Class : WesternFood
Attributes : int foodSet; //1- lamb chop, 2- chicken
//chop, 3 – fish and chip
boolean desert; //true – if wants banana
//pie, otherwise false

Methods : Constructor, mutator, retriever, processor, printer

The customers need to pay extra RM 10.90 if they want the set that comes with dessert.
Besides, 10% discount will be given to the members.

b) Write a Java application which uses the concept of inheritance to:
i. Store data into an array of objects. The number of data to be stored and information
on each of the customers is given by the user.
ii. Display the details of customer’s information, including the payment.

iii. Count and display the number of customers who make a desert order.
iv. Calculate and display the total amount from the member’s customers.
v. Calculate and display the total amount of charges for all customers.

vi. Display the details of customer’s information who make an order the Lamb Chop set.
1.2 Given the following superclass named Artist and subclasses named Performer and
Painter.
Superclass
Attributes:
Methods:
:
:
:
Artist
String artistProfession;
//singer/musician/actor painter/animator
String artistName; //artist name
double payment; //payment for the given service
constructor, mutator, retriever, printer
Subclass
Attributes:
Methods:
:
:
:
Performer
int workingHours; // total of working hour
String genre;// e.g: rock/r&b/theater/magician
constructor, mutator, retriever, printer, processor method
Subclass
Attributes:
Methods:
:
:
:
Painter
int numOfPainting; //number of paintings
painted //by painter
constructor, mutator, retriever, printer, processor method

The total payment for performer based on payment of the given service and working hour (payment
* working hour). If the total of working hour is more than 24 hours, extra allowance RM500.00 need
to be added to the total payment
Meanwhile, the total payment for painter is calculated based on the payment and the number of
painting (payment * number of painting). A token of appreciation, that worth 10% of total payment
will be given if the number of paintings more than five (5).

Answer the following questions by implementing the inheritance concepts:
a) Complete the above classes by considering the following methods:
i. Write the default and normal constructor for class.
ii. Write the mutator for each class
iii. Write the accessor for each class
iv. Write the printer for each class to return object information
v. Write a method named payArtist() for each subclass to calculate and return the
total payment paid to customers.

b) Write a Java application program for each of the following question:
i. Declare an array of object to store FIFTY (50) data on various types of artists and store
data onto the object.
ii. Display the details of Performer objects from the Rock genre which receives
payment for more than RM 10000.00
iii. Display the details of Painter objects which sold more than 10 painting.

1.3 By referring to the Final Examination Paper (Feb 2023), QUESTION 3. Write a complete Java
program.
1.4 By referring to the Final Examination Paper (August 2022), QUESTION 3. Write a complete Java
program.
1.5 By referring to the Final Examination Paper (February 2022), QUESTION 3. Write a complete Java
program.
1.6 By referring to the Final Examination Paper (July 2021), QUESTION 2. Write a complete Java
program.

1.7 By referring to the Final Examination Paper (February 2021), QUESTION 2. Write a complete Java
program.
****Please take note EACH class must have the following methods:
a. Constructor (Default/Normal)
b. Setter/Mutator
c. Getter/Retriever/Accessor
d. Processor (if any)
e. Printer.