Question: Please follow the image below when writing in java. Comments on method and classes Bowl : description - Bowl cost - 0 Cone : coneType:

Please follow the image below when writing in java. Comments on method and classesPlease follow the image below when writing in java. Comments on method

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!