Question: Please follow the image below when writing in java. Java doc comments are also needed Create an abstract base class for IceCream, and two concrete
Please follow the image below when writing in java. Java doc comments are also needed 
Create an abstract base class for IceCream, and two concrete classes Bowl and Cone
Bowl:
description - Bowl
cost - 0
Cone:
coneType: enum representing the type of cone
description: will return a title case representation of the coneType enum, with spaces instead of _
cost - Sugar: .75, Waffle: 1.2, Pretzel: 1.8, Chocolate Dipped: 1.5
ConeType:
an Enumeration for the different types of cones, this code will look like:
public enum ConeType {
SUGAR_CONE,
WAFFLE_CONE,
PRETZEL_CONE,
CHOCOLATE_DIPPED_CONE
}
Then in other files you can refer to the enum like: ConeType.WAFFLE_CONE, you can see an example of this in the driver.
ScoopDecorator:
Constructor: set the iceCream and the numScoops
toString: Will concatenate the following onto the original iceCreams toString
", a scoop of FLAVOR ice cream", or ", NUMSCOOPS scoops of FLAVOR ice cream"
getCost: Adds the cost of each scoop to the original ice creams cost
Vanilla
flavor = "vanilla"
flavorCost = 1.25
Chocolate
flavor = "chocolate"
flavorCost = 1.5
Strawberry
flavor = "strawberry"
flavorCost = 1.4
DRIVER:
package decorator;
public class IceCreamShopDriver { public static void main(String[] args) { IceCream cone = new Cone(ConeType.CHOCOLATE_DIPPED_CONE); IceCream coneFilledIceCream = new Chocolate(new Vanilla(cone, 2), 1);
IceCream bowl = new Bowl(); IceCream bowlFilledIceCream = new Strawberry(new Vanilla(bowl, 1), 1);
System.out.println(" ******** Ice Cream Shop *******");
System.out.println("I would like to order, 2 Ice Creams:"); System.out.println(coneFilledIceCream); System.out.println("Price: $" + coneFilledIceCream.getCost()); System.out.println(" " + bowlFilledIceCream); System.out.println("Price: $" + bowlFilledIceCream.getCost()); } }
OUTPUT:
******** Ice Cream Shop ******* I would like to order, 2 Ice Creams: Chocolate dipped cone, 2 scoops of vanilla ice cream, a scoop of chocolate ice cream Price: $5.5
Bowl, a scoop of vanilla ice cream, a scoop of strawberry ice cream Price: $2.65
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
