Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using java Class TestOrder o Prompt the user to enter customer name and maximum number of desserts in the order. Create an object (order]) from

using java
image text in transcribed
image text in transcribed
image text in transcribed
Class TestOrder o Prompt the user to enter customer name and maximum number of desserts in the order. Create an object (order]) from class Order with the entered information. Then display the following menu until the user choose to exit: 1. Add a new dessert (CupCake) to orderl. Prompt the user to enter all the required information based on that. Display a meaningful message reflecting the success of the addition. - 1. Print all desserts in the orderl. 2. Print total cost of the order. Dessert 1. #flavor: String #size: char + Dessert (flavor String, size: char) + CalculatePrice : double + toString 0: String Order # name: String # numOfDesserts: int + Order (name: String, numOfDesserts: int) AddDessert (in d: Dessert): boolean + GerTotalCost (: double + toString 0: String + get/set methods. desserts CupCake -withfruits: boolean + CupCake (flavor: String, size: char, withfruits: boolean) + Calculate Price : double + toString 0: String +get/set methods Dessert CupCake Attributes Flavor: a string to represent dessert flavor, such as Vanilla, Chocolate, Strawberry...etc. Size: a character to represent dessert size where S for small, M for medium and L for large size. Methods Dessert (flavor: String, size: char) >> constructor to initialize flavor and size with the received parameters. Calculate Price (): double >> returns price of the dessert, it should return 0.0. toString(): String >> returns a string representation of Dessert object Attributes Withfruits: a boolean to indicate whether the cupcake includes fruits or not. Methods CupCake (flavor: String, size: char, withfruits: boolean) >> constructor to initialize flavor, size, and withfruits with the received parameters. Calculate Price (): double >> calculates the price of the cupcake based on its size: S costs 6 SR M costs 10 SR L costs 12 SR There is an extra 3 SR for adding fruits. toString (): String >> returns a string representation of Cup Cake object. Order Attributes Name: a string to represent the customer name. NumOfDesserts: an integer to track the number of the desserts currently in the order Methods Order (name: String, num OfDesserts: int) >> constructor to initialize the name and the size of the DessertList array that you will create. AddDessert (in d: Dessert): boolean >> adds the received object in the first empty location in the DessertList array. The method returns true if the addition was successful and false otherwise. Get TotalCost (): double >> returns the total cost of the whole order. toString(): String >> returns a string representation of Order object and all the desserts in the list

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

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago