Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

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_2

Step: 3

blur-text-image_3

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

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions