Skip to content

Burger KIOSK- Console Application in java #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
388 changes: 388 additions & 0 deletions Burger Application in java
Original file line number Diff line number Diff line change
@@ -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;j<i;j++) {
while(ch3==arr[j])
{
System.out.println("You have aleady selected this option. "+" Select something different.");
ch3=in.nextInt();
j=0;
}

}


if(ch3==0)
break;
else
arr[i]=ch3;


} }
else
if(n==2)
{System.out.println("Which all add ons?Enter 0 to exit");
for( i=0;i<6;i++)
{
ch3=in.nextInt();
while(ch3<0 || ch3>6)
{
System.out.println("Please make a correct choice.");
ch3=in.nextInt();

}
for(int j=0;j<i;j++) {
while(ch3==arr[j])
{
System.out.println("You have aleady selected this option. "+" Select something different.");
ch3=in.nextInt();
j=0;
}

}

if(ch3==0)
break;
else
arr[i]=ch3;


}

}

else
System.out.println("Invalid Choice!");

switch(i)
{
case 0:
break;
case 1:
h.setE(arr[0]);
break;
case 2:
h.setE(arr[0], arr[1]);
break;
case 3:
h.setE(arr[0], arr[1],arr[2]);
break;
case 4:
h.setE(arr[0],arr[1], arr[2], arr[3]);
break;
case 5:
h.setE(arr[0],arr[1], arr[2], arr[3], arr[4]);
break;
case 6:
h.setE(arr[0],arr[1], arr[2], arr[3],arr[4],arr[5]);
break;
}
h.Additions();
System.out.println();
System.out.println();
System.out.println("Please pay $"+h.getTotprice());
System.out.println();
System.out.println("Do visit again!");
}

}