Question: Given the following class: public abstract class Cake1 { protected String name; protected double rate; public Cake1 (String n, double r) { name = n;
Given the following class:
|
- Based on class Cake1 and the following table, define TWO (2) subclasses named as orderCake1 and readymadeCake1.
| OrderCake1 | ReadymadeCake1 | |
| Additional attribute | weight(kg) | quantity |
| Price calculation | rate*weight | rate*quantity |
|
|
|
|
- By using classes definition from a), write an application program that will:
i) declare an array of 4 cake objects (both order and readymade); ii) input data for cake objects and store them into the array; iii) display the total price for all types of cakes; iv) display the total price and the quantity sold for readymade cakes;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
