Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.64 KB | None | 0 0
  1. package com.company;
  2.  
  3. import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class Burger {
  8.     public static Scanner scanner=new Scanner(System.in);
  9. int price=17;
  10. Meat meat_type;
  11. Bread bread;
  12. Additions additions;
  13.  
  14.     public Burger( Meat meat_type, Bread bread, Additions additions) {
  15.         setPrice(price);
  16.         this.meat_type = meat_type;
  17.         this.bread = bread;
  18.         this.additions = additions;
  19.     }
  20.  
  21.     public Burger() {
  22.  
  23.     }
  24.  
  25.     public void setAdditions(Additions additions) {
  26.         this.additions = additions;
  27.     }
  28.  
  29.     public void setPrice(int price) {
  30.         this.price = price;
  31.     }
  32.  
  33.     public int getPrice() {
  34.         return price;
  35.     }
  36.  
  37.     public Meat getMeat_type() {
  38.         return meat_type;
  39.     }
  40.  
  41.     public Bread getBread() {
  42.         return bread;
  43.     }
  44.  
  45.     public Additions getAdditions() {
  46.         return additions;
  47.     }
  48.  
  49.     public Additions add_additions() {
  50.             Additions burger_addition= new Additions(false,false,false,false,false,false,false,false);
  51.             System.out.println("please enter how many 0 to stop adding");
  52.             int input =-1 ;
  53.             while (input != 0) {
  54.                 System.out.println("Please enter what additions you want to put keep in mind it will cost you extra dollar for each\n" +
  55.                         "1.drink\n" +
  56.                         "2.letters\n" +
  57.                         "3.tommato\n" +
  58.                         "4.caret\n" +
  59.                         "5.bbq_souce\n" +
  60.                         "6.tommato_souce\n" +
  61.                         "7.extra_meat\n" +
  62.                         "8.chips");
  63.                 input = scanner.nextInt();
  64.                 switch (input) {
  65.                     case 0:
  66.                         return burger_addition;
  67.                     case 1:
  68.                         burger_addition.setDrink(true);
  69.                         price +=2;
  70.                         break;
  71.                     case 2:
  72.                         burger_addition.setLetters(true);
  73.                        price +=2;
  74.                         break;
  75.                     case 3:
  76.                         burger_addition.setTommato(true);
  77.                         price +=2;
  78.                         break;
  79.                     case 4:
  80.                         burger_addition.setCaret(true);
  81.                         price +=2;
  82.                         break;
  83.                     case 5:
  84.                         burger_addition.setBbq_souce(true);
  85.                         price +=2;
  86.                         break;
  87.                     case 6:
  88.                         burger_addition.setExtra_meat(true);
  89.                         price +=2;
  90.                         break;
  91.                     case 7:
  92.                         burger_addition.setChips(true);
  93.                         price +=2;
  94.                         break;
  95.                     default: {
  96.                         System.out.println("wrong Input");
  97.                         break;
  98.                     }
  99.                 }
  100.  
  101.  
  102.             }
  103.             return burger_addition;}
  104.  
  105.     public Bread add_bread_type(){
  106.         System.out.println("Please Enter the type of of bread: ");
  107.         String bread_type_input=scanner.nextLine();
  108.         System.out.println("Please enter the size of bread Large,small...: ");
  109.         String bread_size_input=scanner.nextLine();
  110.  
  111.         Bread bread_type=new Bread(bread_type_input,bread_size_input);
  112.         return bread_type;
  113.     }
  114.     public Meat add_meat_type(){
  115.         System.out.println("Please Enter the type of meat: ");
  116.         String meat_type_input=scanner.nextLine();
  117.         System.out.println("Please enter the size of meat Large,small...: ");
  118.         String meat_size_input=scanner.nextLine();
  119.  
  120.         Meat meat_type=new Meat(meat_type_input,meat_size_input);
  121.         return meat_type;
  122.     }
  123.     public Burger add_burger(){
  124.  
  125.         Burger burger=new Burger(add_meat_type(),add_bread_type(),add_additions());
  126.         return burger;
  127.     }
  128.     public static String printAdditions(Additions additions){
  129.         String additions_value="";
  130.         String all_addition_values="";
  131.         if(additions.drink){
  132.             additions_value ="Drink";
  133.             all_addition_values+=additions_value+"\n";
  134.         }
  135.         if(additions.chips){
  136.             additions_value="Chips";
  137.             all_addition_values+=additions_value+"\n";
  138.         }
  139.         if(additions.tommato){
  140.             additions_value="tommato";
  141.             all_addition_values+=additions_value+"\n";
  142.         }
  143.         if(additions.bbq_souce){
  144.             additions_value="BBQ Souce";
  145.             all_addition_values+=additions_value+"\n";
  146.         }
  147.         if(additions.letters){
  148.             additions_value="Latters";
  149.             all_addition_values+=additions_value+"\n";
  150.         }
  151.         if(additions.caret){
  152.             additions_value="Carets";
  153.             all_addition_values+=additions_value+"\n";
  154.  
  155.         }
  156.         if(additions.tommato_souce){
  157.             additions_value="Tommato souce";
  158.             all_addition_values+=additions_value+"\n";
  159.  
  160.         }
  161.         return all_addition_values;
  162.     }
  163.  
  164.     public static void printBriger(Burger burger){
  165.         System.out.println("The price is "+ burger.price +" for this burger");
  166.         System.out.println("The additions are\n" + printAdditions(burger.getAdditions()));
  167.     }
  168.  
  169.  
  170. }
  171. package com.company;
  172.  
  173. import static com.company.Burger.printBriger;
  174.  
  175. public class Main {
  176.  
  177.     public static void main(String[] args) {
  178.     Burger burger=new Burger();
  179.     Burger burgers=burger.add_burger();
  180.     printBriger(burgers);
  181.  
  182.  
  183.  
  184.     }
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement