Question: I need help implementing TieredCaked into my java code as it extends my cake class and toppedCake class below, I have attached my Cake and
I need help implementing TieredCaked into my java code as it extends my cake class and toppedCake class below, I have attached my Cake and ToppedCake classes below as well the instructions to follow for TieredCake.
Cake class:
public class Cake extends Dessert { protected double priceOfCake; public Cake(String name, double priceOfCake) { super(name); this.priceOfCake = priceOfCake; } public double getPrice(){ return priceOfCake; } } ToppedCake :
public class ToppedCake extends Cake { public ToppedCake(ToppedCake toppedCake,Dessert dessert ){ super(toppedCake.getName() + "topped with " +dessert.getName(), toppedCake.getPrice() +dessert.getPrice()); } } Below are the instructions for TieredCake:
The TieredCake class should also be derived from the Cake class. This kind of cake has two tiers, so it is constructed from two Cake items. The price of a tiered cake is the sum of the prices of the two individual cakes plus 10% of the total. The TieredCake constructor should take two Cake objects for the lower and upper tiers, in that order. The name of a TieredCake is the name of the lower tier concatenated with the String with an upper tier of and the name of the upper tier. Note that since TieredCake extends Cake, the tiers of a TieredCake may themselves be TieredCakes, or they may be ToppedCakes or just Cakes
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
