Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 classesimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Second International Conference Acids Hue City Vietnam March 2010 Proceedings Part 1 Lnai 5990

Authors: Manh Thanh Le ,Jerzy Swiatek ,Ngoc Thanh Nguyen

2010th Edition

3642121446, 978-3642121449

More Books

Students also viewed these Databases questions