-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMobileShopCounter.java
115 lines (94 loc) · 2.27 KB
/
MobileShopCounter.java
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package Solutions;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
interface MobileShop {
public void modelNo();
public void price();
}
class Iphone implements MobileShop {
@Override
public void modelNo() {
System.out.println(" Iphone 6 ");
}
@Override
public void price() {
System.out.println(" Rs 65000.00 ");
}
}
class Samsung implements MobileShop {
@Override
public void modelNo() {
System.out.println(" Samsung galaxy tab 3 ");
}
@Override
public void price() {
System.out.println(" Rs 45000.00 ");
}
}
class Blackberry implements MobileShop {
@Override
public void modelNo() {
System.out.println(" Blackberry Z10 ");
}
@Override
public void price() {
System.out.println(" Rs 55000.00 ");
}
}
class ShopKeeper {
private MobileShop iphone;
private MobileShop samsung;
private MobileShop blackberry;
public ShopKeeper() {
iphone = new Iphone();
samsung = new Samsung();
blackberry = new Blackberry();
}
public void iphoneSale() {
iphone.modelNo();
iphone.price();
}
public void samsungSale() {
samsung.modelNo();
samsung.price();
}
public void blackberrySale() {
blackberry.modelNo();
blackberry.price();
}
}
public class MobileShopCounter {
private static int choice;
public static void main(String args[]) throws NumberFormatException, IOException {
do {
System.out.print("========= Mobile Shop ============ \n");
System.out.print(" 1. IPHONE. \n");
System.out.print(" 2. SAMSUNG. \n");
System.out.print(" 3. BLACKBERRY. \n");
System.out.print(" 4. Exit. \n");
System.out.print("Enter your choice: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
choice = Integer.parseInt(br.readLine());
ShopKeeper sk = new ShopKeeper();
switch (choice) {
case 1: {
sk.iphoneSale();
}
break;
case 2: {
sk.samsungSale();
}
break;
case 3: {
sk.blackberrySale();
}
break;
default: {
System.out.println("Nothing You purchased");
}
return;
}
} while (choice != 4);
}
}