-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathKonaklamaUI.java
150 lines (132 loc) · 5.43 KB
/
KonaklamaUI.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class KonaklamaUI {
public void main() throws IOException {
System.out.println("=================================================================================");
System.out.println("\n\t\t\t\tKONAKLAMA BOLUMUMUZE HOSGELDINIZ\n");
System.out.println("=================================================================================");
kullanici();
}
public void kullanici() throws IOException {
String choice = "", city="";
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int flag=-1, i=0;
do {
do {
System.out.println("Asagidaki konaklama seceneklerinden birini giriniz:");
System.out.println("\t1- Otel\n\t2- Apart\n\t3- Kiralik Ev\n\t4- Cikis");
choice = br.readLine();
} while (!(choice.equals("1")) && !(choice.equals("2")) && !(choice.equals("3"))&& !(choice.equals("4")));
if(choice.equals("4")) {
System.out.println("Tekrar bekleriz :)");
return;
}
String temp="";
do {
try {
flag=0;
System.out.println("Asagida belirtilen sehirlerden birinin numarasini giriniz:");
System.out.println("1- ANKARA\n" +
"2- ANTALYA\n" +
"3- BOLU\n" +
"4- BURSA\n" +
"5- GAZI ANTEP\n" +
"6- ISTANBUL\n" +
"7- IZMIR\n" +
"8- MUGLA\n" +
"9- NEVSEHIR\n" +
"10- TRABZON\n");
temp = br.readLine();
i = Integer.parseInt(temp);
}catch(NumberFormatException e){
System.out.println("Bir SAYI giriniz.");
flag=-1;
}
}while( i<1 || i>10 || flag==-1 );
flag=-1;
switch (i){
case 1:
city = "ANKARA";
break;
case 2:
city = "ANTALYA";
break;
case 3:
city = "BOLU";
break;
case 4:
city = "BURSA";
break;
case 5:
city = "GAZI ANTEP";
break;
case 6:
city = "ISTANBUL";
break;
case 7:
city = "IZMIR";
break;
case 8:
city = "MUGLA";
break;
case 9:
city = "NEVSEHIR";
break;
case 10:
city = "TRABZON";
break;
}
Konaklama k;
if (choice.equals("1"))
k = new Otel(city);
else if (choice.equals("2"))
k = new Apart(city);
else
k = new KiralikEv(city);
if(k.size==0){
System.out.println("Bilgi bulunamadi. Lütfen başka bir seçenekle tekrar deneyiniz.");
choice="e";
continue;
}
System.out.println(k);
do {
do {
System.out.println("İstediginiz islemi giriniz:");
System.out.println("\t1- Fiyata göre sırala\n\t2- Detaylı bilgi\n\t3- Sistemden cikis");
choice = br.readLine();
} while (!(choice.equals("1")) && !(choice.equals("2")) && !(choice.equals("3")));
if (choice.equals("1"))
k.sortByPrice();
else if (choice.equals("2")) {
do{
System.out.print("Istediginiz yerin numarasini giriniz:");
i=0; flag=0;
try{
choice = br.readLine();
i = Integer.parseInt(choice);
}catch(NumberFormatException e) {
System.out.println(choice + "girildi. Bir SAYI giriniz");
flag=-1;
}
}while(i<=0 || i>k.size || flag==-1);
if(k instanceof Otel)
k.showEnable(i);
System.out.println(" ");
k.showExtra(k.getLoc(i));
} else {
System.out.println("Tekrar bekleriz :)");
return;
}
do{
System.out.println("Baska islem yapmak ister misiniz?(E/H)");
choice = br.readLine();
}while(!(choice.equals("E")) && !(choice.equals("H")) && !(choice.equals("e")) && !(choice.equals("h")));
}while( choice.equals("E") || choice.equals("e") );
do{
System.out.println("Geri dönmek ister misiniz?(E/H)");
choice = br.readLine();
}while(!(choice.equals("E")) && !(choice.equals("H")) && !(choice.equals("e")) && !(choice.equals("h")));
}while(choice.equals("E") || choice.equals("e"));
}
}