size() is allowed for ArrayList
removeNewIngredient() in DessertPlanning returns true if the ingredient was successfully removed, false if not (as indicated by the method signature).
Rules:
In Java 1.8
Dessert.java create Cake.java create Pastry.java create FrozenDessert.java create Cookies.java create ButterCake.java create FoamCake.java create Pie.java create Cobbler.java create IceCream.java create Frozen Yogurt.java create MoldedCookies.java create NoBakeCookies.java create PieType.java create Ingredient.java create Dessert Planning.java create An interface class An abstract class An abstract class An abstract class An abstract class Subclass of Cake Subclass of Cake Subclass of Pastry Subclass of Pastry Subclass of Frozen Dessert Subclass of FrozenDessert Subclass of Cookies Subclass of Cookies enum enum Dessert Planning class that uses the Dessert type The only library you can import is import java.util.ArrayList; The main method will not be tested; you may use it any way you want. You may use add(), remove(), get() for ArrayList. All data fields should be declared private or protected. UML: Butter Cake +baseCosto: double +ingredients Needed(): Ingredient description) String Cake FoamCake +description)String +baseCost/): double ingredients Needed(): Ingredient +description String Ple +type: PleType +PicPleType +Piel) setPleType(PleType: vold +getPieType(): PieType +baseCostly double ingredients Neededly Ingredient) +description(): String > PleType Cream Fruit Custard 1 > Dessert Pastry Dessert Planning dessert Dessert lewingredients: ArrayList
- tewPrices: ArrayList Ingredient E Sugar Butter Flour Baking Powder Baking Soda Flavoring Fruit Salt Milk Cinnamon Cream Yogurt Culture Gelatin price: double Ingredient[double) +getPrice: double +baseCost: double ingredients Needed(): Ingredient description(); String Frozen Dessert Frozen Yogurt +description(): String +baseCost: double ingredients Needed): Ingredient description(String MoltedCookies +baseCosto: double Ingredients Needed(): Ingredient[] description String Cookles +descriptions String NoBakCookies +baseCostly double ingredients Neededly Ingredient() +description: String 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), BakingSoda(.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 FoamCake +baseCost(): double +ingredientsNeeded(): Ingredient[] +description(): String +baseCost(): double +ingredients Needed(): Ingredient[] +description(): String The ingredients set for ButterCake are Eggs, Sugar, Butter, Flour, BakingPowder. 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 FrozenDessert class. Both classes define the methods as set by the interface. Ice Cream Frozen Yogurt +baseCost(): double +ingredientsNeeded(): Ingredient[] +description(): String +baseCost(): double +ingredients Needed(): Ingredient[] +description(): String The ingredients set for IceCream are Milk, Sugar, Gelatin, Eggs, Flavoring. The ingredients set for Frozen Yogurt are Milk, Sugar, Yogurt Culture, 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 NoBake Cookies 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(): Pie Type +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. 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. DessertPlanning 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 -newPrices: ArrayList +Dessert Planning(Dessert) +printBaseIngredients(): void +printBase Price(): void +addNewingredient(String, Double): void +removeNewingredient(String): boolean +printAll ingredients(): 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 new Prices 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 +printBasePrice() 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. tremoveNewIngredient(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 Dessert.java create Cake.java create Pastry.java create FrozenDessert.java create Cookies.java create ButterCake.java create FoamCake.java create Pie.java create Cobbler.java create IceCream.java create Frozen Yogurt.java create MoldedCookies.java create NoBakeCookies.java create PieType.java create Ingredient.java create Dessert Planning.java create An interface class An abstract class An abstract class An abstract class An abstract class Subclass of Cake Subclass of Cake Subclass of Pastry Subclass of Pastry Subclass of Frozen Dessert Subclass of FrozenDessert Subclass of Cookies Subclass of Cookies enum enum Dessert Planning class that uses the Dessert type The only library you can import is import java.util.ArrayList; The main method will not be tested; you may use it any way you want. You may use add(), remove(), get() for ArrayList. All data fields should be declared private or protected. UML: Butter Cake +baseCosto: double +ingredients Needed(): Ingredient description) String Cake FoamCake +description)String +baseCost/): double ingredients Needed(): Ingredient +description String Ple +type: PleType +PicPleType +Piel) setPleType(PleType: vold +getPieType(): PieType +baseCostly double ingredients Neededly Ingredient) +description(): String > PleType Cream Fruit Custard 1 > Dessert Pastry Dessert Planning dessert Dessert lewingredients: ArrayList - tewPrices: ArrayList Ingredient E Sugar Butter Flour Baking Powder Baking Soda Flavoring Fruit Salt Milk Cinnamon Cream Yogurt Culture Gelatin price: double Ingredient[double) +getPrice: double +baseCost: double ingredients Needed(): Ingredient description(); String Frozen Dessert Frozen Yogurt +description(): String +baseCost: double ingredients Needed): Ingredient description(String MoltedCookies +baseCosto: double Ingredients Needed(): Ingredient[] description String Cookles +descriptions String NoBakCookies +baseCostly double ingredients Neededly Ingredient() +description: String 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), BakingSoda(.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 FoamCake +baseCost(): double +ingredientsNeeded(): Ingredient[] +description(): String +baseCost(): double +ingredients Needed(): Ingredient[] +description(): String The ingredients set for ButterCake are Eggs, Sugar, Butter, Flour, BakingPowder. 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 FrozenDessert class. Both classes define the methods as set by the interface. Ice Cream Frozen Yogurt +baseCost(): double +ingredientsNeeded(): Ingredient[] +description(): String +baseCost(): double +ingredients Needed(): Ingredient[] +description(): String The ingredients set for IceCream are Milk, Sugar, Gelatin, Eggs, Flavoring. The ingredients set for Frozen Yogurt are Milk, Sugar, Yogurt Culture, 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 NoBake Cookies 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(): Pie Type +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. 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. DessertPlanning 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 -newPrices: ArrayList +Dessert Planning(Dessert) +printBaseIngredients(): void +printBase Price(): void +addNewingredient(String, Double): void +removeNewingredient(String): boolean +printAll ingredients(): 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 new Prices 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 +printBasePrice() 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. tremoveNewIngredient(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