Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package Chapter5Test;
- /*Ch5 Performance Test
- Interface Program
- 1) Asks for and accepts orders for one sandwich, one drink, and
- up to 2 side dishes.
- 2) A null response to any item is acceptable
- 3) The parameters to be passed to the instance variables for having the
- sandwich toasted or cut should be set to "Y" or "N"
- */
- //Menu Interface Program
- import java.util.Scanner;
- public class Chapter5Test
- {
- public static void main (String [] args)
- {
- Scanner reader = new Scanner(System.in);
- Sandwiches Sandwich1; // one sandwich
- Drinks Drink1; // one drink
- Sides Side1;
- Sides Side2; // two side dishes
- //Private variables to accept responses to items for the order
- String MainIngrd, SecIngrd, ExtLayer, Cond, Fix ,Side, Size, Serve,
- Beverage,toaststatus, Y_N = "";
- Sandwich1 = new Sandwiches();
- Drink1 = new Drinks();
- Side1 = new Sides();
- Side2 = new Sides();
- //reader.nextLine();
- // Request the input
- System.out.print("What type of sandwich would you like? ");
- MainIngrd = reader.nextLine();
- Sandwich1.SetMainIngredient(MainIngrd);
- System.out.print("What additional ingredient would you like? ");
- SecIngrd = reader.nextLine();
- Sandwich1.SetSecIngredient(SecIngrd);
- System.out.print("How would you like your sandwich enclosed? ");
- ExtLayer = reader.nextLine();
- Sandwich1.SetExteriorLayer(ExtLayer);
- System.out.println("Please enter the first of 3 possible condiments ");
- System.out.print("Press enter if you do not wish a condiment ");
- Cond = reader.nextLine();
- Sandwich1.SetCondiment(Cond,1);
- System.out.println("Please enter the second of 3 possible condiments ");
- System.out.print("Press enter if you do not wish a condiment ");
- Cond = reader.nextLine();
- Sandwich1.SetCondiment(Cond,2);
- System.out.println("Please enter the third of 3 possible condiments ");
- System.out.print("Press enter if you do not wish a condiment ");
- Cond = reader.nextLine();
- Sandwich1.SetCondiment(Cond,3);
- System.out.println("Please enter the first of 2 possible fixings ");
- System.out.print("Press enter if you do not wish a fixing ");
- Fix = reader.nextLine();
- Sandwich1.SetFixing(Fix,1);
- System.out.println("Please enter the second of 2 possible fixings ");
- System.out.print("Press enter if you do not wish a fixing ");
- Fix = reader.nextLine();
- Sandwich1.SetFixing(Fix,2);
- System.out.print("Please enter how you would like your sandwich served? ");
- Serve = reader.nextLine();
- Sandwich1.SetService(Serve);
- System.out.print("Would you like to have your sandwich toasted? (Enter Toasted or not Toasted)");
- toaststatus = reader.nextLine();
- Sandwich1.SetToast(Y_N);
- System.out.print("Would you like to have your sandwich cut? (Y/N)");
- Y_N = reader.nextLine();
- Sandwich1.SetCut(Y_N);
- System.out.print("What would you like to drink? ");
- Beverage = reader.nextLine();
- System.out.print("What size? ");
- Size = reader.nextLine();
- Drink1.SetDrink(Beverage,Size);
- System.out.println("Please enter the first of 2 possible side dishes ");
- System.out.print("Press enter if you do not wish a side dish ");
- Side = reader.nextLine();
- System.out.print("What size? ");
- Size = reader.nextLine();
- Side1.SetSide(Side,Size);
- System.out.println("Please enter the second of 2 possible side dishes ");
- System.out.print("Press enter if you do not wish a side dish ");
- Side = reader.nextLine();
- System.out.print("What size? ");
- Size = reader.nextLine();
- Side2.SetSide(Side,Size);
- System.out.println(Sandwich1);
- System.out.println(Drink1);
- System.out.println(Side1);
- System.out.println(Side2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement