QuestionQuestion

Exercises

All operations will be performed on the PizzaParty database. The schema for PizzaParty is reviewed below.

1. Below is a stub for the class OurPizzaParty. Default and initialization constructors are provided for you. The method menu will be the entry point into the functionality you provide. You are allowed to implement other methods and classes as they are useful to your solution. The class PizzaPartyDriver is also given to provide an example of how your system will be tested.

2. After each of the query operations listed here, display [print] relevant results. When executing the user’s currently built SQL statement, display all the tuples returned.

3. Provide the user with a menu system that facilitates the following operations. In our solution, we will not be deleting elements from the database. This means that once an order has been made, it will not be removed from the database. Note, operations / menu selection will continue until the user chooses to stop. Here is the menu you will implement, followed by the functionality included within that implementation.

Menu: provide a numeric menu for selection options. The user will input the number associated with the option and this cycle will continue until they choose to end the program (3).

(1) Execute a complete SQL command
(2) Build an Order
(3) Logout / End Program

More information about the options:

• Entering a complete SQL command. Note, this would only be useful to users who know how to write SQL statements. Inexperienced users would leverage the other options.

• Build Order. This will take the user through a steps collecting necessary information (User’s name and desired restaurant) and leading them to another numerical submenu to build their order. Build Order should be implemented as follows:
Step #1 Prompt user to enter their name
Step #2 Print a list of available restaurants and allow the user to select a Restaurant from this list [via a numeric menu]  Step #3 Take the user to the menu of actions:
(1) Add Pizza
• Print specialty pizza options available at the restaurant.
• Allow the user to select one [via a numeric menu].
(2) Finalize Order
• Print the pizzas in this order using the name collected in step #1.
o Point Distribution
User interaction flow. The program should properly store input in the database.
Selections are properly assembled into SQL queries.
Queries are executed on the proper tables and columns.
Logout/ End Program. The program receives new selections until the user choose to end the program.

The PizzaParty Schema

Customer (Customer_Name, Address, Phone_Number) Restaurant(Restaurant_Name, Address, Phone_Number) Car(Model, Make)
Driver(Car_Number, Driver_Name, Model, Restaurant_Name) Restaurant_Name refers to the employer of the driver.
Toppings(Topping_Name, Food_Group, Calories) Crust(Crust_Style, Size, Restaurant_Name, Price) Flavor(Flavor_Name, Restaurant_Name, Price)
Flavor_Toppings (Flavor_Name, Restaurant_Name, Topping_Name) Sauce (Sauce_Name, Restaurant_Name)
Pizza(Pizza_ID, Flavor_Name, Crust_Style, Size, Restaurant_Name, Sauce_Name) Price of a pizza is the sum of prices of the flavor and the crust.
Contains entries for individual pizzas of an order.
If an order contains multiple pizzas of same type, each will have different entry in pizza table with a different Pizza_ID (other attributes will remain same.)
Orders(Order_ID, Customer_Name, Restautrant_Name, Is_Delivery, Car_Number) Price of the order is the sum of prices of all the pizzas included in the order. Is_Delivery can be “YES” or “NO”.
If Is_Delivery is “NO”, Car_Number should be NULL. Order_Pizza(Order_ID, Pizza_ID)
Mapping between Order and Pizza.

*A successful order will add new entries in Pizza, Order, and Order_Pizza tables.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.sql.*;
import java.util.*;

public class hw10 {

    public static void main(String[] args) {
       PizzaPartyDriver.main(args);
    }
}

class PizzaPartyDriver {

    public static void main(String args[]) {
       OurPizzaParty opp = new OurPizzaParty();
       opp.menu();
    }
}

class OurPizzaParty {

    private String database;
    private String username;
    private String password;

    private DBConnection dbc;
    private static Scanner scanner = new Scanner(System.in);

    public OurPizzaParty() {
       database = "PizzaParty";
       username = "root";
       //password = "";
       password = "root";
    }

    public OurPizzaParty(String database, String username, String password) {
       this.database = database;
       this.username = username;
       this.password = password;
    }

    public void menu() {
       // implement your menu
       dbc = new DBConnection();
       if (dbc.openConnection(database, username, password) == false) {
            return;
       }

       int selection;
       String[] message = {
            "***** Main Menu *****",
            " [1] Execute SQL Query",
            " [2] Build an Order",
            " [3] Quit"
       };

       do {
            selection = getSelection(message, 1, 3);
            switch (selection) {
                case 1:
                   sqlCommand();
                   break;
                case 2:
                   buildOrder();
                   break;
            }

       } while (selection != 3);

       dbc.closeConnection();
    }...

By purchasing this solution you'll be able to access the following files:
Solution.java.

$68.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats