Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ===========================================================================================
- PizzaDriver.java
- ===========================================================================================
- /*
- *File name: PizzaDriver.java
- *
- *Programmer: Derek Townsend
- *ULID: djtown1
- *
- *Date: Oct 27, 2017
- *
- *Class: IT 168
- *Lecture Section: 004
- *Lecture Instructor:Dr Xing Fang
- *Lab Section: 005
- *Lab Instructor: Simran Kaur
- */
- package edu.ilstu;
- import java.util.Scanner;
- /*
- *<insert description>
- *
- * @author Derek
- *
- */
- public class PizzaDriver
- {
- public static void main(String[] args)
- {
- boolean phoneFlag=true, addressFlag=true;
- String userAddress="" ,fullName="" ,phoneNumber="" ,address="" ,deliveryOrder="" , confirmOrder="";
- Scanner keyboard =new Scanner(System.in);
- Customer customer1=new Customer();
- Store store1=new Store();
- Order order1=new Order();
- PizzaBuilder pizza1= new PizzaBuilder();
- System.out.print("Welcome to ILSTU pizza store, lets cook your Pizza \n" +
- "First: is this for a pickup or delivery? type 1 for pickup, 2 for delivery\n Answer: ");
- deliveryOrder=keyboard.next();
- order1.setOrderType(deliveryOrder);
- if(order1.getOrderType().equals("pickup order")){
- System.out.print("Pick a location that is close to you by typing 1, 2 or 3:\n" +
- "\t1-207 W north st, Normal IL\n" +
- "\t2-305 S main st, Normal IL\n" +
- "\t3-208 landmark, Bloomington IL\n" +
- "Answer: ");
- address=keyboard.next();
- while(addressFlag==true) {
- if (address.equals("1")||address.equals("2")||address.equals("3")) {
- addressFlag=false;
- }else {
- addressFlag=true;
- System.out.println("Try again, not a valid location");
- address=keyboard.next();
- }
- store1.pickingLocation(address);
- }
- }else if(order1.getOrderType().equals("delivery")){
- System.out.print("\nPlease enter your full name: ");
- keyboard.nextLine();
- fullName=keyboard.nextLine();
- System.out.print("Please enter the address: ");
- userAddress=keyboard.nextLine();
- System.out.print("\nPlease provide the phone number starting with the area code: ");
- phoneNumber=keyboard.next();
- while(phoneFlag==true) {
- if (phoneNumber.length()==10) {
- phoneFlag=false;
- }else if((phoneNumber.length()<10)) {
- phoneFlag=true;
- System.out.println("Too short, try again");
- phoneNumber=keyboard.next();
- }else if(phoneNumber.length()>10) {
- phoneFlag=true;
- System.out.println("Too long, try again");
- phoneNumber=keyboard.next();
- }
- }
- }
- customer1.readInformation(fullName, userAddress, phoneNumber);
- System.out.print(pizza1.chooseSauce());
- pizza1.setSauce(keyboard.next());
- System.out.print("\nTopping list: \n" +
- "\t1-onion\n" +
- "\t2-olives\n" +
- "\t3-tomato\n" +
- "\t4-mushrooms\n" +
- "\t5-green peppers\n" +
- "\t6-Pepperoni\n"
- );
- pizza1.chooseTopping();
- boolean flag2=true;
- int counter=-1;
- while(flag2==true){
- counter++;
- System.out.print("Do you want to add another? type yes or no\n");
- String anotherTopping=keyboard.next();
- if(anotherTopping.equalsIgnoreCase("yes")) {
- pizza1.chooseTopping();
- }else if(anotherTopping.equalsIgnoreCase("no")){
- flag2=false;
- }
- }
- pizza1.setNumOfToppings(counter);
- System.out.println("do you want extra cheese, its Free :)? Type Y for Yes or N for No ");
- pizza1.setCheese(keyboard.next());
- if(order1.getOrderType().equals("pickup order")){
- System.out.println("Order Summary: \n" +
- "______________ \n" +
- "This is a "+order1.getOrderType() +
- ", location of the store to pickup from is "+
- store1.getLocation()+"\n" +
- " The pizza will have "+
- pizza1.getSauce() +
- " sauce, with "+
- pizza1.getCheese()+
- ", and "+pizza1.determineTopping() +" toppings\n");
- order1.summary(pizza1.getNumOfToppings());
- }else if(order1.getOrderType().equals("delivery")){
- System.out.println("Order Summary: \n" +
- "______________ \n" +
- "This is a "+order1.getOrderType() +
- " order, deliver to "+
- customer1.getFullName()+"\nAddress: " +
- customer1.getAddress()+
- "\nPhone number to call in case we got lost \n"+
- customer1.getPhoneNumber()+
- "\n The pizza will have "+
- pizza1.getSauce() +
- " sauce, with "+
- pizza1.getCheese()+
- ", and "+pizza1.determineTopping() +" toppings\n");
- order1.summary(pizza1.getNumOfToppings());
- }
- System.out.println("Do you want to place the order? type y for Yes and n for No");
- confirmOrder=keyboard.next();
- boolean cheeseflag=true;
- while(cheeseflag==true) {
- if(!confirmOrder.equalsIgnoreCase("Y")&&!confirmOrder.equalsIgnoreCase("N")) {
- System.out.println("This is not a valid response please enter a new one");
- confirmOrder=keyboard.next();
- cheeseflag=true;
- }else if(confirmOrder.equalsIgnoreCase("Y")){
- System.out.println("Your pizza will be ready in 30 min, Thanks for doing business with us.");
- cheeseflag=false;
- }else if(confirmOrder.equalsIgnoreCase("N")){
- System.out.println("Thanks for wasting our time. Please don't visit us again.");
- cheeseflag=false;
- }
- }
- keyboard.close();
- }
- }
- ===========================================================================================
- PizzaDriver.java
- ===========================================================================================
- /*
- *File name: Order.java
- *
- *Programmer: Derek Townsend
- *ULID: djtown1
- *
- *Date: Oct 26, 2017
- *
- *Class: IT 168
- *Lecture Section: 004
- *Lecture Instructor:Dr Xing Fang
- *Lab Section: 005
- *Lab Instructor: Simran Kaur
- */
- package edu.ilstu;
- import java.util.Scanner;
- /*
- *<insert description>
- *
- * @author Derek
- *
- */
- public class Order
- {
- private String orderType;
- public final int TOPPING_PRICE=5;
- public final double SALES_TAX=1.075;
- public final double DELIVERY_CHARGE=.20;
- Scanner keyboard =new Scanner(System.in);
- public void setOrderType(String deliveryOrPickup) {
- boolean orderFlag=true;
- while(orderFlag==true) {
- if (deliveryOrPickup.equals("1")||deliveryOrPickup.equals("2")) {
- orderFlag=false;
- }else {
- orderFlag=true;
- System.out.println("Wrong choice, please type 1 for pickup and 2 for delivery");
- deliveryOrPickup=keyboard.next();
- }
- }
- if (deliveryOrPickup.equals("1")) {
- orderType="pickup order";
- }else if(deliveryOrPickup.equals("2")) {
- orderType="delivery";
- }
- }
- public String getOrderType() {
- return orderType;
- }
- public void summary(int numOfToppings) {
- double subtotal,total,deliveryCharge;
- if (orderType.equals("pickup order")) {
- subtotal=TOPPING_PRICE+(numOfToppings);
- total=subtotal*SALES_TAX;
- System.out.printf("The subtotal is:\t\t$%,.2f \n",subtotal);
- System.out.printf("The total cost is:\t\t$%,.2f \n",total);
- }else if(orderType.equals("delivery")) {
- subtotal=TOPPING_PRICE+(numOfToppings);
- deliveryCharge=subtotal*DELIVERY_CHARGE;
- total=(subtotal+deliveryCharge)*SALES_TAX;
- System.out.printf("The subtotal is:\t\t$%,.2f \n",subtotal);
- System.out.printf("The delivery charge is:\t\t$%,.2f \n",deliveryCharge);
- System.out.printf("The total cost is:\t\t$%,.2f \n",total);
- }
- }
- }
- ===========================================================================================
- PizzaDriver.java
- ===========================================================================================
- /*
- *File name: PizzaBuilder.java
- *
- *Programmer: Derek Townsend
- *ULID: djtown1
- *
- *Date: Oct 26, 2017
- *
- *Class: IT 168
- *Lecture Section: 004
- *Lecture Instructor:Dr Xing Fang
- *Lab Section: 005
- *Lab Instructor: Simran Kaur
- */
- package edu.ilstu;
- import java.util.Scanner;
- /*
- *<insert description>
- *
- * @author Derek
- *
- */
- public class PizzaBuilder
- {
- private String sauce,cheese,currentToppings="";
- private int numOfToppings;
- Scanner keyboard =new Scanner(System.in);
- public String chooseSauce() {
- return "\nSecond, lets build your pizza\r\n" +
- "Pick a source by typing the sauce:\n" +
- "List of sauces: "+
- "\n\t\tSalsa"+
- "\n\t\tBBQ "+
- "\n\t\tTapenade"+
- "\n\t\tPesto "+
- "\n\t\tBechamel \n" +
- "Answer: ";
- }
- public String chooseTopping() {
- String topping="";
- boolean flag=true;
- while(flag==true) {
- System.out.print("Pick Topping from the list above ");
- int choice=keyboard.nextInt();
- switch (choice) {
- case 1:
- topping="Onion";
- break;
- case 2:
- topping="Olives";
- break;
- case 3:
- topping="Tomato";
- break;
- case 4:
- topping="Mushrooms";
- break;
- case 5:
- topping="Green Peppers";
- break;
- case 6:
- topping="Pepperoni";
- break;
- }
- if(currentToppings.contains(topping)) {
- System.out.println("You already have this topping please Select new topping");
- flag=true;
- }else {
- currentToppings+=" "+topping;
- flag=false;
- }
- }
- return currentToppings;
- }
- public void chooseCheese() {
- }
- public String determineTopping() {
- return currentToppings;
- }
- public void setSauce(String sauce) {
- boolean sauceflag=true;
- while(sauceflag==true) {
- if(sauce.equalsIgnoreCase("Salsa")) {
- this.sauce="Salsa";
- sauceflag=false;
- }else if(sauce.equalsIgnoreCase("BBQ")) {
- this.sauce="BBQ";
- sauceflag=false;
- }else if(sauce.equalsIgnoreCase("Tapenade")) {
- this.sauce="Tapenade";
- sauceflag=false;
- }else if(sauce.equalsIgnoreCase("Pesto")) {
- this.sauce="Pesto";
- sauceflag=false;
- }else if(sauce.equalsIgnoreCase("Bechamel")) {
- this.sauce="Bechamel";
- sauceflag=false;
- }else{
- System.out.println("This is not a valid response please enter a new one");
- sauce=keyboard.next();
- sauceflag=true;
- }
- }
- }
- public void setCheese(String cheese) {
- boolean cheeseflag=true;
- while(cheeseflag==true) {
- if(cheese.equalsIgnoreCase("Y")) {
- this.cheese="extra cheese";
- cheeseflag=false;
- }else if(cheese.equalsIgnoreCase("N")){
- this.cheese="normal cheese";
- cheeseflag=false;
- }else {
- System.out.println("This is not a valid response please enter a new one");
- cheese=keyboard.next();
- cheeseflag=true;
- }
- }
- }
- public void setNumOfToppings(int numOfToppings) {
- this.numOfToppings=numOfToppings;
- }
- public String getSauce() {
- return sauce;
- }
- public String getCheese() {
- return cheese;
- }
- public int getNumOfToppings() {
- return numOfToppings;
- }
- }
- ===========================================================================================
- PizzaDriver.java
- ===========================================================================================
- /*
- *File name: Customer.java
- *
- *Programmer: Derek Townsend
- *ULID: djtown1
- *
- *Date: Oct 26, 2017
- *
- *Class: IT 168
- *Lecture Section: 004
- *Lecture Instructor:Dr Xing Fang
- *Lab Section: 005
- *Lab Instructor: Simran Kaur
- */
- package edu.ilstu;
- /*
- *Keeps track of the customer name, address, and phone number.
- *
- * @author Derek
- *
- */
- public class Customer
- {
- private String fullName,address,phoneNumber;
- public void readInformation(String fullName,String address,String phoneNumber){
- this.fullName=fullName;
- this.address=address;
- this.phoneNumber=phoneNumber;
- }
- public String getFullName() {
- return fullName;
- }
- public String getAddress() {
- return address;
- }
- public String getPhoneNumber() {
- return phoneNumber;
- }
- public String toString() {
- return fullName+" "+address+" "+phoneNumber;
- }
- }
- ===========================================================================================
- PizzaDriver.java
- ===========================================================================================
- /*
- *File name: Store.java
- *
- *Programmer: Derek Townsend
- *ULID: djtown1
- *
- *Date: Oct 26, 2017
- *
- *Class: IT 168
- *Lecture Section: 004
- *Lecture Instructor:Dr Xing Fang
- *Lab Section: 005
- *Lab Instructor: Simran Kaur
- */
- package edu.ilstu;
- ;
- /*
- *This class will keep track of the store location.
- *
- * @author Derek
- *
- */
- public class Store
- {
- private String location;
- public void pickingLocation(String locationNumber) {
- if (locationNumber.equals("1")) {
- location="207 W North St, Normal IL";
- }else if(locationNumber.equals("2")) {
- location="305 S Main St, Normal IL";
- }else if(locationNumber.equals("3")) {
- location="208 Landmark , Bloomington IL ";
- }else {
- location="";
- }
- }
- public String getLocation() {
- return location;
- }
- public String toString() {
- return location;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement