Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this project you will create a Java application that simulates the operations

ID: 3717946 • Letter: I

Question

In this project you will create a Java application that simulates the operations of a pizza shop. Users of the pizza shop application will be able to create a new order, display all created orders, or exit the application.

An order will consist of some number of pizzas, and some number of drinks. Drinks cost $1.99 each. Pizzas are available in three sizes: small, medium, and large. The base price for each pizza is $5.99 for a small pizza, $7.49 for a medium pizza, and $8.99 for a large pizza. Pizzas may also have an unlimited number of toppings; each topping is an additional 75 cents. Finally, we will track the customer's name with each order.

When creating an order, you will first ask for the customer's name. Next, you will ask if the customer wants to add a pizza to their order. If so, ask if they want a small, medium, or large pizza; then, ask the user to enter the toppings they want. (You may find that a sentinel value helps to determine when the user is done specifying toppings.) Perform these steps for each pizza the customer orders.

After the customer finishes ordering pizzas, the application must prompt the user to enter the names of the drinks in the order. The drinks may be entered as String values, such as "Coca-Cola", "Dr Pepper", or "Dasani". (Again, a sentinel value may help the user to specify when they are finished adding drinks to the order.)

At this point, the order is complete. It should be added to the running list of orders.

When a user chooses to display the orders, all orders since the application started must be displayed on the screen. For each order, the customer's name, the pizzas and their toppings, and the drinks must all be displayed, along with the total price for the order. The price of each individual pizza and the total price of the drinks should be displayed, but this is not required.

Below is an example of what the output could be if a user has created two orders:

When the user exits the application, the orders do not have to be saved. However, you may choose to include options to save the orders to a file and reload them later. Students who successfully implement options for users to save the orders to a file and reload them from a file will receive 15 percent extra credit. These options should allow users to specify the name of the file where they want to save or reload the orders. (Probably the easiest way to perform this is to ensure that the Pizza and Order classes implement the java.io.Serializable interface.)

Attached is a zip file containing skeleton versions of the PizzaShop, Order, and Pizza classes. When implementing the Order and Pizza classes, all methods currently in the classes must be implemented, without any change to their methods' signatures. In the PizzaShop class, the methods named main, createOrder, and displayOrdersmust be implemented, and the saveOrdersToFile and loadOrdersFromFile may be implemented for extra credit. The signatures of the methods in PizzaShop may be changed (except for main, of course); however, it is possible to implement these methods and maintain the same signatures.

Upload your changes to the PizzaShop, Order, and Pizza classes by the due date. Make sure you upload your Java source files, not your compiled class files

Explanation / Answer

Pizza.java

package chegg;

import java.util.ArrayList;
import java.util.List;

/**
* Created by Nirupom Biswas on 27-Apr-18.
*/

public class Pizza {
    private int size;
    private List<String> toppings;
    private double price;
    //Small : 5.99
    //Medium : 7.49
    //Large : 8.99
    //Toppings : .75 each


   
public Pizza() {
        price = 0.0;
        toppings=new ArrayList<>();
    }

    public String getSize() {
        if (size == 1)
            return "small";
        else if (size == 2)
            return "medium";
        else return "large";
    }

    public void setSize(String size) {
        if (size.toLowerCase().equals("small")) {
            this.size = 1;
            price += 5.99;
        } else if (size.toLowerCase().equals("medium")) {
            this.size = 2;
            price += 7.49;
        } else {
            this.size = 3;
            price += 8.99;
        }
    }

    public List<String> getToppings() {
        return toppings;
    }

    public void setToppings(List<String> toppings) {
        this.toppings = toppings;
        price += (this.toppings.size() * 0.75);
    }

    public double getPrice() {
        return price;
    }
}

Sample Output

Pizza ordering System

1. New Order

2. Display Orders

3. Exit

1

Enter Customer Name :

nirupom

Add pizza? (y/n) :

y

1. Small : $5.99

2. Medium : $7.49

3. Large : $8.99

4. Exit Pizza

1

Add Toppings? (y/n) :

y

0. Salami

1. Bacon

2. Beef

3. Ham

4. Italian Sausage

5. Philly Steak

6. Premium Chicken

Press 7 when done.

3

2

3

Already Added

4

7

1. Small : $5.99

2. Medium : $7.49

3. Large : $8.99

4. Exit Pizza

2

Add Toppings? (y/n) :

y

0. Salami

1. Bacon

2. Beef

3. Ham

4. Italian Sausage

5. Philly Steak

6. Premium Chicken

Press 7 when done.

2

7

1. Small : $5.99

2. Medium : $7.49

3. Large : $8.99

4. Exit Pizza

3

Add Toppings? (y/n) :

y

0. Salami

1. Bacon

2. Beef

3. Ham

4. Italian Sausage

5. Philly Steak

6. Premium Chicken

Press 7 when done.

7

1. Small : $5.99

2. Medium : $7.49

3. Large : $8.99

4. Exit Pizza

1

Add Toppings? (y/n) :

y

0. Salami

1. Bacon

2. Beef

3. Ham

4. Italian Sausage

5. Philly Steak

6. Premium Chicken

Press 7 when done.

4

7

1. Small : $5.99

2. Medium : $7.49

3. Large : $8.99

4. Exit Pizza

4

Add Drinks? (y/n) :

y

0. Mango Mocktail

1. Blue Shoe

2. Cherry Coketail

3. Gabbie's Punch

4. Tomato Lassi

5. Cranberry Coke

6. Coconut Lavender Lemonade

7. Limeade Punch

Press 8 when done.

5

8

1. New Order

2. Display Orders

3. Exit

2

Order : 1

Name : nirupom

=============== Bill Details ======================

Pizza : 1

Size : small          Toppings : 3

| Ham || Beef || Italian Sausage |Pizza : 2

Size : medium     Toppings : 1

| Beef |Pizza : 3

Size : large           Toppings : 0

Pizza : 4

Size : small          Toppings : 1

| Italian Sausage |

Drinks : 1

| Cranberry Coke |

=============================================

Total Billing Price : 34.2

1. New Order

2. Display Orders

3. Exit

3

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote