/home/sjenks/NetBeansProjects/CS2/src/applications/Bistro.java
  1 /*
  2  * This is a program to imitate a menu 
  3  */
  4 package applications;
  5 
  6 import alist.AList;
  7 import alist.Pair;
  8 import java.util.Scanner;
  9 import java.util.ArrayList;
 10 
 11 /**
 12  *
 13  * @author sjenks
 14  */
 15 public class Bistro {
 16 
 17     /**
 18      * @param args the command line arguments
 19      */
 20     static private AList<String, Double> menu;
 21 
 22     public static void main(String[] args) {
 23         System.out.println("Welcome to the Laker Diner! ");
 24         establishMenu();
 25         interpretOrders();
 26     }
 27 
 28     private static void establishMenu() {
 29         menu = new AList<>();
 30         menu.add(new Pair("Coffee", 1.50));
 31         menu.add(new Pair("Tea", 1.50));
 32         menu.add(new Pair("Soda", 1.00));
 33         menu.add(new Pair("Salad", 2.99));
 34         menu.add(new Pair("Mozzarella Sticks", 3.99));
 35         menu.add(new Pair("Calamari", 5.99));
 36         menu.add(new Pair("Stuffed Mushrooms", 5.99));
 37         menu.add(new Pair("Fish and Chips", 5.99));
 38         menu.add(new Pair("New England Clam Chowder", 4.99));
 39         menu.add(new Pair("Lobster", 10.99));
 40         menu.add(new Pair("Soup Special", 4.99));
 41         menu.add(new Pair("Shrimp on Pasta", 5.99));
 42         menu.add(new Pair("Chocolate Cake", 2.00));
 43         menu.add(new Pair("Cannoli", 2.50));
 44         menu.add(new Pair("Fruit Salad", 2.00));
 45 
 46     }
 47 
 48     private static void interpretOrders() {
 49         System.out.print("Please enter command... " + "\n >>> ");
 50         Scanner directory = new Scanner(System.in);
 51         String command = directory.next();
 52         if (command.equalsIgnoreCase("menu")) {
 53             displaymenu();
 54             interpretOrders();
 55         } else if (command.equalsIgnoreCase("order")) {
 56             order();
 57         } else if (command.equalsIgnoreCase("exit")) {
 58 
 59         } else if (command.equalsIgnoreCase ("help")){
 60             help();
 61         }else{
 62             error();
 63         }
 64 
 65     }
 66 
 67 
 68     private static void displaymenu() {
 69         menu.display();
 70     }
 71 
 72     private static void order() {
 73         Double cost = 0.00;
 74         ArrayList<String> currOrder = new ArrayList<>();
 75         System.out.print("What would you like to order? >>> ");
 76         Scanner scanner = new Scanner(System.in);
 77         String wholeOrder = scanner.nextLine();
 78         Scanner search = new Scanner (wholeOrder);
 79         search.useDelimiter(", ");
 80         while (search.hasNext()) {
 81             String item = search.next();
 82             if (menu.member(item)) {
 83                 currOrder.add(item);
 84                 cost = cost + menu.lookup(item);
 85             }
 86         }
 87 
 88         System.out.println("\n Items of your order..." + currOrder);
 89         System.out.println("\n Total cost..." + cost);
 90         double costWithTax= (cost + (cost*.08));
 91         System.out.println("\n Total cost with tax..." + costWithTax);
 92         double costWithTaxTip = (costWithTax + (costWithTax * .20)); 
 93         System.out.println("\n Total cost with tax and 20% tip..." + costWithTaxTip + "\n");
 94         
 95         
 96 
 97     }
 98 
 99     private static void help() {
100         System.out.println("Your command options are ... "
101                 + " menu | order | exit | help ");
102         interpretOrders();
103     }
104 
105     private static void error() {
106        System.out.println("Sorry I didn't recognized input, Please try again... "
107                 + " menu | order | exit | help ");
108         interpretOrders();
109     }
110 
111 }
112