-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGidilecekYerler.java
252 lines (237 loc) · 8.13 KB
/
GidilecekYerler.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;
public class GidilecekYerler {
private static String sehir;
private static Set<Veri> mekanlar = new HashSet<>();
private static int yer, name;
public static void main(){
Scanner inp1 = new Scanner(System.in);
Scanner inp3 = new Scanner(System.in);
boolean choice = true, cont=false;
String answer;
while (choice) {
boolean city = false;
while (!city){
city = getCity();
}
switch (name) {
case 1:
sehir = "Ankara";
break;
case 2:
sehir = "Antalya";
break;
case 3:
sehir = "Bolu";
break;
case 4:
sehir = "Bursa";
break;
case 5:
sehir = "Gaziantep";
break;
case 6:
sehir = "istanbul";
break;
case 7:
sehir = "izmir";
break;
case 8:
sehir = "Mugla";
break;
case 9:
sehir = "Nevsehir";
break;
case 10:
sehir = "Trabzon";
break;
default:
System.out.println("Lutfen verilen sehirlerden birini seciniz.");
cont = true;
}
if (cont)
continue;
boolean where = false, readerVar = false;
while (!where){
where = neresi();
}
while (!readerVar){
readerVar = readerFunc();
}
System.out.println("Baska bir işlem yapmak istiyor musunuz? (E/H) \n> ");
answer = inp3.nextLine();
if (answer.equals("E") || answer.equals("e")) {
choice = true;
mekanlar.clear();
} else if (answer.equals("H") || answer.equals("h")) {
choice = false;
mekanlar.clear();
}
else{
System.out.println("Hatali secim. Cikis yapiliyor");
System.out.println("Bizi seçtiğiniz için teşekkür ederiz.");
choice = false;
mekanlar.clear();
}
}
System.out.println("Bizi seçtiğiniz için teşekkür ederiz.");
}
public static void reader(int file) throws IOException {
switch (file){
case 1: splitter("dogalguzellikler.csv");
break;
case 2:
splitter("muzeler.csv");
break;
case 3: splitter("restoranlar.csv");
break;
}
}
public static void splitter(String file) throws IOException {
BufferedReader b = new BufferedReader(new FileReader(file));
String row;
String[] cols=new String[10];
while ( (row = b.readLine())!=null) {
cols = row.split(",");
if(cols[0].equals(sehir)) {
Veri veri = new Veri();
veri.setSehirAdi(cols[0]);
veri.setMekanAdi(cols[1]);
veri.setOnBilgi(cols[2]);
veri.setDetayliBilgi(cols[3]);
mekanlar.add(veri);
}
}
boolean displayVar=false;
while(!displayVar){
displayVar = display();
}
}
public static boolean display(){
Scanner scan = new Scanner(System.in);
Scanner scan1 = new Scanner(System.in);
int choice=0;
if (yer==1){
int i=1;
System.out.println(sehir + " ilimizde bulunan dogal guzellikler su sekildedir.");
for (Veri v : mekanlar){
System.out.println(i+" - "+v.mekanAdi+"\n "+v.onBilgi);
i++;
}
System.out.print("Seciminiz : ");
try{
choice = scan.nextInt();
}catch (Exception e2){
return false;
}
if (!(choice==1 || choice == 2 || choice == 3)){
System.out.println("Hatali secim.");
return false;
}
i=1;
for (Veri v : mekanlar){
if (i==choice)
System.out.println(v.mekanAdi+"\n "+v.detayliBilgi);
i++;
}
}
if (yer==2){
int i=1;
System.out.println(sehir + " ilimizde bulunan muze ve oren yerleri su sekildedir.");
for (Veri v : mekanlar){
System.out.println(i+" - "+v.mekanAdi+"\n "+v.onBilgi+"\n");
i++;
}
System.out.print("Seciminiz : ");
try{
choice = scan1.nextInt();
}catch (Exception e1){
System.out.println("Hatali secim.");
return false;
}
if (!(choice==1 || choice == 2 || choice == 3)){
System.out.println("Hatali secim.");
return false;
}
i=1;
for (Veri v : mekanlar){
if (i==choice)
System.out.println(v.mekanAdi+"\n "+v.detayliBilgi+"\n");
i++;
}
}
if (yer==3){
int i=1;
System.out.println(sehir + " ilimizde bulunan yoresel restoranlar su sekildedir.\n");
for (Veri v : mekanlar){
System.out.println(i+" - "+v.mekanAdi+"\n "+v.onBilgi);
i++;
}
System.out.print("Seciminiz : ");
try{
choice = scan1.nextInt();
}catch (Exception e1){
System.out.println("Hatali secim. Cikis yapiliyor.");
return false;
}
if (!(choice==1 || choice == 2 || choice == 3)){
System.out.println("Hatali secim.");
return false;
}
i=1;
for (Veri v : mekanlar){
if (i==choice)
System.out.println(v.mekanAdi+"\n "+v.detayliBilgi+"\n");
i++;
}
}
return true;
}
private static boolean neresi(){
Scanner inp2 = new Scanner(System.in);
Scanner inp4 = new Scanner(System.in);
System.out.print("Nereye gitmek istiyosunuz?\n1 - Doğal Güzellikler\n2 - Müzeler ve Ören Yerleri\n3 - Restoranlar\n>");
try {
yer = inp2.nextInt();
} catch (Exception e) {
return false;
}
if (!(yer == 1 || yer == 2 || yer == 3)) {
System.out.println("Hatali secim.");
return false;
}
return true;
}
private static boolean readerFunc(){
try {
reader(yer);
} catch (Exception e) {
System.err.println("Hatali input " + e);
return false;
}
return true;
}
private static boolean getCity(){
System.out.println("1- ANKARA\n" +
"2- ANTALYA\n" +
"3- BOLU\n" +
"4- BURSA\n" +
"5- GAZİANTEP\n" +
"6- İSTANBUL\n" +
"7- İZMİR\n" +
"8- MUĞLA\n" +
"9- NEVŞEHİR\n" +
"10- TRABZON\n");
System.out.println("Gitmek istediğiniz şehri şeçiniz: ");
Scanner reader = new Scanner(System.in); // Reading from System.in
try {
name = reader.nextInt(); // Scans the next token of the input as an int.
} catch (Exception e) {
System.out.println("Sayi giriniz.");
return false;
}
return true;
}
}