Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ui;
- import java.util.ArrayList;
- import java.util.List;
- import javax.swing.JOptionPane;
- import domain.Pizza;
- public class Menu {
- public String showWelcomeScreen(){
- String[] options = {"checkMenu", "getPizzas", "pizzaIngredients", "cheaperPizzas", "vegetarian", "addPizza", "price", "submitOrder", "orderState", "cancelOrder"};
- return (String) JOptionPane.showInputDialog(null, "Make a choice", "Pizza menu", JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
- }
- public List<String> addPizza(){
- List<String> ingredients = new ArrayList<String>();
- String ingredient = "";
- String endCase = "";
- do {
- ingredient = (String) JOptionPane.showInputDialog("Which ingredient do you want to have on your pizza?");
- if(ingredient == null || (ingredient != null && ("".equals(ingredient)))){
- endCase = "end";
- } else
- ingredients.add(ingredient);
- } while(!endCase.equals("end"));
- return ingredients;
- }
- public void showResponse(String message){
- JOptionPane.showMessageDialog(null, message);
- showWelcomeScreen();
- }
- public void showResponseList(List<String> cheaperPizzas){
- String listItemsToShow = "Cheaper pizzas:\n";
- for(String pizza : cheaperPizzas)
- listItemsToShow += pizza + "\n";
- JOptionPane.showMessageDialog(null, listItemsToShow);
- showWelcomeScreen();
- }
- public void showResponseListAllPizzas(List<Pizza> pizzas){
- String listItemsToShow = "All pizzas:\n";
- for(Pizza pizza : pizzas)
- listItemsToShow += pizza + "\n";
- JOptionPane.showMessageDialog(null, listItemsToShow);
- showWelcomeScreen();
- }
- public String askPizzaName(){
- return JOptionPane.showInputDialog("Give the pizza name where you want to know the ingredient from:");
- }
- /*private String[] listToArray(List<String> cheaperPizzas){
- String[] cheapP = new String[cheaperPizzas.size()];
- return cheaperPizzas.toArray(cheapP);
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment