Hellboyandso

ui_Menu.java

Dec 12th, 2016
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.90 KB | None | 0 0
  1. package ui;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import javax.swing.JOptionPane;
  7.  
  8. import domain.Pizza;
  9.  
  10. public class Menu {
  11.  
  12.     public String showWelcomeScreen(){
  13.         String[] options = {"checkMenu", "getPizzas", "pizzaIngredients", "cheaperPizzas", "vegetarian", "addPizza", "price", "submitOrder", "orderState", "cancelOrder"};
  14.         return (String) JOptionPane.showInputDialog(null, "Make a choice", "Pizza menu", JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
  15.     }
  16.    
  17.     public List<String> addPizza(){
  18.         List<String> ingredients = new ArrayList<String>();
  19.         String ingredient = "";
  20.         String endCase = "";
  21.         do {
  22.             ingredient = (String) JOptionPane.showInputDialog("Which ingredient do you want to have on your pizza?");
  23.             if(ingredient == null || (ingredient != null && ("".equals(ingredient)))){
  24.                 endCase = "end";
  25.             } else
  26.                 ingredients.add(ingredient);
  27.         } while(!endCase.equals("end"));
  28.         return ingredients;
  29.     }
  30.    
  31.     public void showResponse(String message){
  32.         JOptionPane.showMessageDialog(null, message);
  33.         showWelcomeScreen();
  34.     }
  35.    
  36.     public void showResponseList(List<String> cheaperPizzas){
  37.         String listItemsToShow = "Cheaper pizzas:\n";
  38.         for(String pizza : cheaperPizzas)
  39.             listItemsToShow += pizza + "\n";
  40.         JOptionPane.showMessageDialog(null, listItemsToShow);
  41.         showWelcomeScreen();
  42.     }
  43.    
  44.     public void showResponseListAllPizzas(List<Pizza> pizzas){
  45.         String listItemsToShow = "All pizzas:\n";
  46.         for(Pizza pizza : pizzas)
  47.             listItemsToShow += pizza + "\n";
  48.         JOptionPane.showMessageDialog(null, listItemsToShow);
  49.         showWelcomeScreen();
  50.     }
  51.    
  52.     public String askPizzaName(){
  53.         return JOptionPane.showInputDialog("Give the pizza name where you want to know the ingredient from:");
  54.     }
  55.    
  56.     /*private String[] listToArray(List<String> cheaperPizzas){
  57.         String[] cheapP = new String[cheaperPizzas.size()];
  58.         return cheaperPizzas.toArray(cheapP);
  59.     }*/
  60. }
Advertisement
Add Comment
Please, Sign In to add comment