From a1a7ec6c6cf17f05416f7855ec6c6698ad574a86 Mon Sep 17 00:00:00 2001 From: Vasvisood <56781981+Vasvisood@users.noreply.github.com> Date: Sat, 31 Oct 2020 21:43:20 +0530 Subject: [PATCH] Create Burger Application in java --- Burger Application in java | 388 +++++++++++++++++++++++++++++++++++++ 1 file changed, 388 insertions(+) create mode 100644 Burger Application in java diff --git a/Burger Application in java b/Burger Application in java new file mode 100644 index 0000000..34157e0 --- /dev/null +++ b/Burger Application in java @@ -0,0 +1,388 @@ +class DeluxeBurger extends Hamburger{ + private int potatop=10,coldp=10; + public DeluxeBurger(String bread, String meat, int price) { + super(bread, meat, price, "Deluxe Burger"); + super.setTotp(super.getTotprice()+potatop+coldp); + + } + + @Override + public void Additions() { + + super.Additions(); + System.out.println("Potato Chips :"+potatop); + System.out.println("Cold Drink :"+coldp); + } + + @Override + public int getBasePrice() { + // TODO Auto-generated method stub + return super.getBasePrice(); + } + + @Override + public int getTotprice() { + + return super.getTotprice(); + } +} + +public class Hamburger { +private String bread,meat,name; + int e1,e2,e3,e4,e5,e6; + private int price,totp; + private int tomatop=2, onionp=1,mayop=3,cheesep=5,lettucep=4,cornp=4; + + void setE5(int e5) + { + this.e5 = e5; + } + void setE6(int e6) + { + this.e6 = e6; + } + void setTotp(int tot) + { + this.totp=tot; + } + + + +public Hamburger(String bread, String meat, int price, String name) { + super(); + this.bread = bread; + this.meat = meat; + this.price = price; + this.name = name; + this.totp=price; +} + + + +public int getBasePrice() { + return price; +} +public void Additions() + +{ + + System.out.println("***********************************************************************************************************"); + System.out.println(" BILL's Burgers "); + System.out.println("Add On's you opted for :"); + if(e1==1||e2==1||e3==1||e4==1||e5==1||e6==1) { + System.out.println("Tomatoes: $"+tomatop); + totp+=tomatop; + + } + + + + if(e1==2||e2==2||e3==2||e4==2||e5==2||e6==2) { + System.out.println("Onions: $"+onionp); + totp+=onionp; + + } + + if(e1==6||e2==6||e3==6||e4==6||e5==6||e6==6) { + System.out.println("Mayo: $"+mayop); + totp+=mayop; + + } + if(e1==5||e2==5||e3==5||e4==5||e5==5||e6==5) { + System.out.println("Cheese: $"+cheesep); + totp+=cheesep; + + } + if(e1==3||e2==3||e3==3||e4==3||e5==1||e6==3) { + System.out.println("Lettuce: $"+lettucep); + totp+=lettucep; + + } + if(e1==4||e2==4||e3==4||e4==4||e5==4||e6==4) { + System.out.println("Corn: $"+cornp); + totp+=cornp; + + } + if(e1==0 ) { + System.out.println("No additional toppings selected "); + + + } + + +} + + + + + + + + + +public int getTotprice() { + return totp; +} + + + + + + + +public void setE(int arr) { + this.e1 = arr; +} + + + +public void setE(int arr,int arr2) { + this.setE(arr); + this.e2 = arr2; +} + + +public void setE(int arr,int arr2,int arr3) { + this.setE(arr,arr2); + + this.e3 = arr3; +} + + +public void setE(int arr,int arr2,int arr3,int arr4) { + this.setE(arr,arr2,arr3); + this.e4 = arr4; +} +/*public void setE(int arr,int arr2,int arr3,int arr4, int arr5) +{ + System.out.println("Cannot take more than 4 add ons"); +} +public void setE(int arr,int arr2,int arr3,int arr4, int arr5, int arr6) +{ + System.out.println("Cannot take more than 4 add ons"); +}*/ +public void setE(int i, int j, int k, int l, int m) { + // TODO Auto-generated method stub + +} +public void setE(int i, int j, int k, int l, int m, int n) { + // TODO Auto-generated method stub + +} +} + + + + + + class HealthyBurger extends Hamburger { + +public HealthyBurger(String meat, int price, String name) { + super("brown rye", meat, price, "Healty Burger"); + // TODO Auto-generated constructor stub +} +public void setE(int e1,int e2,int e3,int e4,int e5) { + super.setE(e1, e2, e3, e4); + super.setE5(e5); +} +public void setE(int e1,int e2,int e3,int e4,int e5,int e6) { + setE(e1, e2, e3, e4,e5); + super.setE6(e6); +} +@Override +public int getBasePrice() { + return super.getBasePrice(); +} +@Override +public void Additions() { + super.Additions(); +} +@Override +public int getTotprice() { + // TODO Auto-generated method stub + return super.getTotprice(); +} +} + import java.util.Scanner; + +public class Main { + + + public static void main(String[] args) { + + int ch1,ch2,ch3 =0, i = 0; int n;String bread = null,meat = null; int[] arr= new int[6]; + Scanner in=new Scanner(System.in); + System.out.println("********************************************************************************************************"); + + System.out.println("What would you like to have today?\n1.Regular Burger\n2.Healthy Burger\n3.Deluxe Burger"); + n=in.nextInt(); + + + + while(!(n==1|| n==2||n==3)) + { + System.out.println("Please make a correct choice."); + n=in.nextInt(); + + + } + + + + + if(n==1|| n==3) { + System.out.println("Choose bread\n1.White\n2.Brown rye"); + ch1=in.nextInt(); + switch(ch1) + { + case 1: + bread="White"; + + break; + case 2: + bread="Brown Rye"; + break; + default: + while(!(ch1==1|| ch1==2)){ + System.out.println("Please make a correct choice."); + ch1=in.nextInt(); + } + } + + } + + System.out.println("Choose your choice of meat\n1.Beef\n2.Chicken\n3.Lamb"); + ch2=in.nextInt(); + switch(ch2) + { + case 1: + meat="Beef"; + + break; + case 2: + bread="Chicken"; + break; + case 3: + meat="Lamb"; + break; + default: + while(!(ch2==1|| ch2==2||ch2==3)){ + System.out.println("Please make a correct choice."); + ch2=in.nextInt(); + } + } + Hamburger h=null; + switch(n) + { + + case 1: + h=new Hamburger(bread,meat,20,"Regular Hamburger"); + break; + case 2: + h=new HealthyBurger(meat,20,"Healthy Burger"); + + break; + case 3: + h =new DeluxeBurger(bread,meat,20); + + break; + + } + + System.out.println("Choice of Add on's:\n1.Tomatoes\n2.Onions\n3.Lettuce\n4.Corn\n5.Cheese\n6.Mayo"); + if(n==1||n==3) { + System.out.println("Which all add ons?Choose a maximum of 4.Enter 0 to exit"); + for( i=0;i<4;i++) + { + ch3=in.nextInt(); + while(ch3<0 || ch3>6) + { + System.out.println("Please make a correct choice."); + ch3=in.nextInt(); + + } + for(int j=0;j6) + { + System.out.println("Please make a correct choice."); + ch3=in.nextInt(); + + } + for(int j=0;j