Wednesday, June 21, 2017

Point Of Sales

Tags

Following code will print the point of sales at any Restaurant:

Code:
interface order{
int addItem(int x);
}
class order1 {
int totalvalue;
StringBuffer order=new StringBuffer() ;
order o;
void addVegBurger(int x) {
o=new vegburger();
totalvalue+=o.addItem(x);
order.append("VegBurger    *"+x+"   : \u20b9"+x*50+"\n");
}
void addNonVegBurger(int x) {
o=new nonvegburger();
totalvalue+=o.addItem(x);
order.append("NonVegBurger *"+x+"   : \u20b9"+x*70+"\n");
}
void addFries(int x) {
o=new fries();
totalvalue+=o.addItem(x);
order.append("Fries        *"+x+"   : \u20b9"+x*50+"\n");
}
void addCoke(int x) {
o=new coke();
totalvalue+=o.addItem(x);
order.append("Coke         *"+x+"   : \u20b9"+x*40+"\n");
}
void showOrder() {
System.out.println("-------Your Order-------");
System.out.println(order);
System.out.println("Total Amount    :  \u20b9"+totalvalue);
System.out.println("       Thank You!!\n    Please Visit Again!!");

}
}
class vegburger implements order{
public int addItem(int x) {
return x*50;
}
}
class nonvegburger implements order {
public int addItem(int x) {
return x*70;
}
}
class fries implements order {
public int addItem(int x) {
return x*50;
}
}
class coke implements order {
public int addItem(int x) {
return x*40;
}
}

public class POS {

public static void main(String[] nt) {
order1 o=new order1();
o.addVegBurger(3);
o.addNonVegBurger(1);
o.addCoke(4);
o.addFries(4);
o.showOrder();
}

}

Output: