Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA PROGRAMMING PLEASE! DESSERT This will be used as a starting point for deriving any specific Dessert type. Every Dessert type has one or more

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

JAVA PROGRAMMING PLEASE!

DESSERT This will be used as a starting point for deriving any specific Dessert type. Every Dessert type has one or more ingredient; therefore, a Dessert has the following abstract methods: > Dessert +baseCost(): double +ingredientsNeeded(): Ingredient[] +description(): String +double baseCost() returns the total price based on all the base ingredients used for a dessert. +String description() a method that returns the name of the dessert type. +Ingredient[] ingredients Needed() a method that returns the ingredient(s) used by a dessert. Note that the return type of the method is Ingredient. Define an enum datatype called Ingredient. The enum contains the following values (see below UML) and a constructor which sets the price for each ingredient. The enum also contains a getter method which returns the price per ingredient. The prices of the ingredient values are initialized as: Eggs(3.48), Sugar(2.89), Butter(3.99), Flour(3.24), Baking Powder(1.99), Baking Soda(.85), Flavoring(2.99), Fruit(5.50), Salt(.99), Milk(2.72), Cinnamon(2.99), Cream(3.12), YogurtCulture(4.95), Gelatin(3.99). > Ingredient Eggs Sugar Butter Flour Baking Powder Baking Soda Flavoring Fruit Salt Milk Cinnamon Cream Yogurt Culture Gelatin -price: double +Ingredient(double) +getPrice(): double CAKE, PASTRY, FROZENDESSERT, COOKIES The different desserts are categorized into four different dessert groups. Namely: Cake, Pastry, Frozen Dessert and Cookies. These four classes are abstract and implements the Dessert class. Cake Pastry +description(): String +description(): String Frozen Dessert Cookies +description(): String +description(): String The strings returned by each class are: Cake, Pastry, Frozen Dessert", "Cookies" (respectively). BUTTERCAKE, FOAMCAKE These classes derive from the Cake class. Both classes define the methods as set by the interface. ButterCake Foam Cake +baseCost(): double +ingredientsNeeded(): Ingredient[] +description(): String +baseCost(): double +ingredients Needed(): Ingredient[] +description(): String The ingredients set for ButterCake are Eggs, Sugar, Butter, Flour, Baking Powder. The ingredients set for FoamCake are Eggs, Sugar, Butter, Flavoring. The description strings the classes return are: Foam Cake, Butter Cake (respectively). ICECREAM, FROZEN YOGURT These classes derive from the Frozen Dessert class. Both classes define the methods as set by the interface. IceCream Frozen Yogurt +base Cost(): double +ingredientsNeeded(): Ingredient[] +description(): String +baseCost(): double +ingredientsNeeded(): Ingredient[] +description(): String The ingredients set for IceCream are Milk, Sugar, Gelatin, Eggs, Flavoring. The ingredients set for Frozen Yogurt are Milk, Sugar, YogurtCulture, Flavoring. The description strings the classes return are: Frozen Yogurt, Ice Cream (respectively). MOLDED COOKIES, NOBAKECOOKIES These classes derive from the Cookies class. Both classes define the methods as set by the interface. Molded Cookies NoBake Cookies +baseCost(): double +ingredientsNeeded(): Ingredient[] +description(): String +baseCost(): double +ingredientsNeeded(): Ingredient[] +description(): String The ingredients set for MoldedCookies are Flour, Sugar, Baking Soda, Baking Powder, Milk, Cream, Butter. The ingredients set for NoBakeCookies are Sugar, Butter, Milk, Flavoring. The description strings the classes return are: No-Bake Cookies, Molded Cookies (respectively). COBBLER This class derive from the Pastry class. This class define the methods as set by the interface. Cobbler +baseCost(): double +ingredientsNeeded(): Ingredient[] +description(): String The ingredients set for Cobbler are Fruit, Sugar, Salt, Butter, Flour, Baking Powder, Milk, Cinnamon. The description string the class return is: Cobbler. PIE This class derive from the Pastry class. This class define the methods as set by the interface; and set ingredients based on three different PieType. Pie Type is an enum as shown in the UML below. Pie +type: PieType +Pie(PieType) +Pie() +setPieType(PieType): void +getPieType(): PieType +baseCost(): double +ingredientsNeeded(): Ingredient[] +description(): String > PieType Cream Fruit Custard The default constructor sets the member variable type to Cream by default. The parameterized constructor sets the member variable type to the passed in PieType. tset PieType(PieType) is the mutator for member variable type. +getPieType() is the accessor for member variable type. The ingredients set for the different pies are: o Cream Pie: Milk, Cream, Sugar, Flour, Eggs. o Fruit Pie: Fruit, Sugar, Salt, Flour, Butter, Eggs. o Custard Pie: Milk, Cream, Sugar, Eggs. The description string the class return is: "Custard Pie", "Fruit Pie", or "Cream Pie based on the PieType. . DESSERT PLANNING DessertPlanning is used to plan for any Dessert type. Dessert Planning allows the printing of base ingredients and price for any Dessert. It allows for new ingredients to be added or removed. It allows for calculating the total price of baking a particular dessert based on the base cost and any new costs. Dessert Planning -dessert: Dessert -newIngredients: ArrayList -new Prices: ArrayList +Dessert Planning(Dessert) +printBaselngredients(): void +printBasePrice(): void +addNewingredient(String, Double): void +removeNewIngredient(String): boolean +printAllingredients(): void +printTotalPrice(): void Member Variables: Dessert object, a String ArrayList and a Double ArrayList. Constructor allows the initialization of the member Dessert object to a passed in value. Sets newIngredients and newPrices to a new String ArrayList and Double ArrayList (respectively). printBaseIngredients() uses System.out.println() to print out each of the base ingredients of the dessert. Example: Butter Cake Base Ingredients: Eggs $3.48 Sugar $2.89 Butter $3.99 Flour $3.24 Baking Powder $1.99 tprintBasePrice() uses System.out.println() to print out the base cost of the dessert. Example: Base Cost: $15.59 taddNewIngredient(String, Double) populates the member String and Double ArrayLists. tremoveNew Ingredient(String) removes an ingredient from the String ArrayList and the corresponding price from the Double ArrayList. +printAllIngredients() uses System.out.println() to print out all the ingredients based on the base ingredients and the new ingredients added. Example: Butter Cake Base Ingredients: Eggs $3.48 Sugar $2.89 Butter $3.99 Flour $3.24 Baking Powder $1.99 New Ingredients: Vanilla Extract $2.44 +printTotalPrice() uses System.out.println() to print the total cost based on the base cost and the new ingredients. Example: Total Cost: $18.03 ICECREAM, FROZEN YOGURT These classes derive from the Frozen Dessert class. Both classes define the methods as set by the interface. IceCream Frozen Yogurt +base Cost(): double +ingredientsNeeded(): Ingredient[] +description(): String +baseCost(): double +ingredientsNeeded(): Ingredient[] +description(): String The ingredients set for IceCream are Milk, Sugar, Gelatin, Eggs, Flavoring. The ingredients set for Frozen Yogurt are Milk, Sugar, YogurtCulture, Flavoring. The description strings the classes return are: Frozen Yogurt, Ice Cream (respectively). MOLDED COOKIES, NOBAKECOOKIES These classes derive from the Cookies class. Both classes define the methods as set by the interface. Molded Cookies NoBake Cookies +baseCost(): double +ingredientsNeeded(): Ingredient[] +description(): String +baseCost(): double +ingredientsNeeded(): Ingredient[] +description(): String The ingredients set for MoldedCookies are Flour, Sugar, Baking Soda, Baking Powder, Milk, Cream, Butter. The ingredients set for NoBakeCookies are Sugar, Butter, Milk, Flavoring. The description strings the classes return are: No-Bake Cookies, Molded Cookies (respectively)

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

Mastering Real Time Analytics In Big Data A Comprehensive Guide For Everyone

Authors: Lennox Mark

1st Edition

B0CPTC9LY9, 979-8869045706

More Books

Students also viewed these Databases questions

Question

To find the integral of 3x/(x - 1)(x - 2)(x - 3)

Answered: 1 week ago

Question

What are Fatty acids?

Answered: 1 week ago

Question

What are Electrophoresis?

Answered: 1 week ago