Question: You have been given the task to create a computer system to take orders from a pizza restaurant. You need to store the following information
You have been given the task to create a computer system to take orders from a pizza restaurant. You need to store the following information about the pizzas: name, array of ingredients (maximum 5), crust type, and price. The price of a pizza is calculated with a base price of $2 and $0.50 cents for each ingredient. You are going to start by implementing the class Pizza that will contain the following:
Attributes, based on the description above.
Default constructor
Constructor that receives only the name of the pizza.
Setter methods for the attributes name, crust type and price
Getter methods for the attributes name, crust type and price.
Method called addIngredient() that receives an ingredient at a time and stores it in the array of ingredients. Make sure you keep track of the ingredients you have so far so it does not exceed 5.
Method called calculatePrice() that returns the total price of the pizza based on the number of ingredients.
Once you create the Pizza class do the Order class. The Order class will contain the following.
Attributes: name of client, array of Pizza(capacity 10), and the total price.
Default constructor.
Constructor that only receives the name of the client
Setter method for the name of the client
Getter method for the name of the client and the total price.
Create a method called addPizza() that receives an object of type Pizza and stores it in the array of Pizza. Make sure you keep track of the number of pizzas added.
Create a method called calculateTotal() that calculates the total amount to be paid based on the pizzas ordered. This method should return the total price which includes an 8.25% of taxes
In your Order class include a main method that executes the following intructions:
1. Ask the client for his/her name
2. Create an object of type Order
3. Ask the client if they would like to order a pizza, if the client answers yes ask for the ingredients and add the pizza to the order.
4. Repeat step 2 until the client answers no.
5. When the client answers no, calculate the total and display the following message: Thank you! Your total is ____ (add the calculated total to this message)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
