-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFriedRise.java
More file actions
82 lines (70 loc) · 1.93 KB
/
FriedRise.java
File metadata and controls
82 lines (70 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package org.billGeneration;
public class FriedRise {
private int price;
private boolean veg;
private int ExtraMayoPrice=20;
private int ExtraKetchupPrice=15;
private int ExtraCokePrice=30;
private int ExtraPepsiPrice=20;
private int packingprice=20;
private int baseFriedRise;
private boolean isExtraMayoAdded=false;
private boolean isExtraKetchupAdded=false;
private boolean isExtraCokeAdded=false;
private boolean isExtraPepsiAdded=false;
private boolean isOptedForTakeAway=false;
public FriedRise(boolean veg) {
this.veg=veg;
if(this.veg) {
this.price=140;
}else {
this.price=180;
}
baseFriedRise=this.price;
}
public void addExtraMayo() {
isExtraMayoAdded = true;
System.out.println("Extra Mayonaise Added");
this.price+=ExtraMayoPrice;
}
public void addExtraKetchup() {
isExtraKetchupAdded = true;
System.out.println("Extra Ketchup Added");
this.price+=ExtraKetchupPrice;
}
public void addExtraCoke() {
isExtraCokeAdded=true;
System.out.println("Extra Coke Added");
this.price+=ExtraCokePrice;
}
public void addExtraPepsi() {
isExtraPepsiAdded=true;
System.out.println("Extra Pepsi Added");
this.price+=ExtraPepsiPrice;
}
public void takeAway() {
isOptedForTakeAway=true;
this.price+=packingprice;
}
public void getBill() {
String bill="";
System.out.println("FriedRise :"+baseFriedRise);
if(isExtraMayoAdded) {
bill+="Extra Mayonaise Added: "+ExtraMayoPrice+"\n";
}
if (isExtraKetchupAdded) {
bill+="Extra Ketchup Added: "+ExtraKetchupPrice+"\n";
}
if (isExtraCokeAdded) {
bill+="Extra Coke Added: "+ExtraCokePrice+"\n";
}
if (isExtraPepsiAdded) {
bill+="Extra Pepsi Added: "+ExtraPepsiPrice+"\n";
}
if (isOptedForTakeAway) {
bill+="Is Opted for TakeAway: "+packingprice+"\n";
}
bill+="Bill : "+this.price+"\n";
System.out.println(bill);
}
}