Answered step by step
Verified Expert Solution
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
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: ArrayListStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started