You are on page 1of 1

(4 marks) You have main function which is saved on folder named Q41 already.

Use these classes


and function to test all your operations in this question, DO NOT EDIT ANY CODE in main. You
can add more operations/classes/interfaces to be able to answer the below questions.
We had provided you:
1. Interface – ICake which will declare some operations on Cake – DO NOT EDIT this one.
2. You only need to complete the code in class MyCake and Cake.
Design and code a class named Cake that holds information about a Cake. Information of a Cake
includes:
 Floating-values describing the price and imported tax of a Cake.
 A string describing the name of a Cake.

Include the following member functions in your design:


 Constructors to set values for instance variables.
 Add needed operations to the class so that the main function can be run.

Design and code a class named MyCake which will implement interface ICake and complete 2
methods which were declared in ICake.
 String getHighestPrice(ArrayList a) – return the name of the first Cake in the list of Cakes
which has highest sales price (sales price = price + imported tax).
 int count(ArrayList a) – count and return the number of Cake that have imported tax less than
the imported tax of the first Cake in the list.

The program output might look something like:

You might also like