-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathJMCarado.java
More file actions
377 lines (309 loc) · 13 KB
/
JMCarado.java
File metadata and controls
377 lines (309 loc) · 13 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
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
import java.util.Scanner;
public class JMCarado {
public static void showToDo(String[] myArray) {
int i = 1;
System.out.println("==========================================");
for (String todo : myArray) {
System.out.println(i + ". " + todo);
i++;
}
System.out.println("==========================================");
}
public static boolean eat(String meal) {
System.out.println("\n == == You are eating with " + meal + " as a meal.");
try {
Thread.sleep(500);
for (int i = 0; i <= 2; i++) {
System.out.println(" == == Eating...");
Thread.sleep(1500);
}
} catch (InterruptedException e) {
// Handle interrupted exception (e.g., log or rethrow)
Thread.currentThread().interrupt(); // Restore the interrupted status
}
System.out.println(" == == Done eating!");
return true;
}
public static boolean shower(String soap, String shampoo) {
System.out.println("\n == == You are currently in the shower.");
try {
System.out.println(" == == You are using " + soap + " as your soap.");
Thread.sleep(1500);
System.out.println(" == == You are using " + shampoo + " as your shampoo.");
Thread.sleep(1500);
} catch (InterruptedException e) {
// Handle interrupted exception (e.g., log or rethrow)
Thread.currentThread().interrupt(); // Restore the interrupted status
}
return true;
}
public static boolean exercise(int sets) {
System.out.println();
try {
for (int set = 1; set <= sets; set++) {
System.out.println(" == == You are currently exercising @ Set " + set + ". ");
Thread.sleep(200);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
System.out.println(" == == You are now done with " + sets + " sets of exercises.");
return true;
}
public static boolean nap(int minutes) {
System.out.println("\n == == You are about to take a nap.");
try {
for (int i = 0; i < minutes; i++) {
System.out.println(" == == Napping...");
Thread.sleep(600);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
System.out.println(" == == You have now woken up after " + minutes + " minutes of napping");
return true;
}
public static boolean code(int hours, String language) {
System.out.println("\n == == You are about to code");
try {
for (int i = 1; i <= hours; i++) {
System.out
.println(" == == You have been coding with " + language + " language for " + i
+ " hour(s) now.");
Thread.sleep(100);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt(); // Restore the interrupted status
}
System.out.println(" == == You have now finished coding for " + hours + " hours with " + language + ".");
return true;
}
public static boolean game(int hours, String game) {
System.out.println("\n == == You are about to play a game");
try {
for (int i = 1; i <= hours; i++) {
System.out
.println(" == == You have been playing with " + game + " game for " + i
+ " hour(s) now.");
Thread.sleep(600);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt(); // Restore the interrupted status
}
System.out.println(" == == You have now finished gaming for " + hours + " hours with " + game + ".");
return true;
}
public static boolean halfbath(int minutes) {
System.out.println("\n == == You are about to take a half bath.");
try {
for (int i = 1; i <= minutes; i++) {
System.out.println(" == == Half Bathing...");
Thread.sleep(600);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt(); // Restore the interrupted status
}
System.out.println(" == == You have now finished your half bath for " + minutes + " minutes.");
return true;
}
public static boolean brushteeth(String toothpaste) {
System.out.println("\n == == You are about to brush your teeth");
try {
for (int i = 0; i <= 2; i++) {
System.out.println(" == == Brushing...");
Thread.sleep(600);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt(); // Restore the interrupted status
}
System.out.println(
" == == You have now finished brushing your teeth with " + toothpaste + " as your toothpaste.");
return true;
}
public static boolean morning(Scanner inputInt, Scanner inputStr) {
String[] MorningtoDo = { "Breakfast", "Shower", "Exercise" };
boolean mtd1 = false;
boolean mtd2 = false;
boolean mtd3 = false;
while (!(mtd1 && mtd2 && mtd3)) {
System.out.println("\nMORNING ROUTINE");
showToDo(MorningtoDo);
System.out.println("0 to skip morning routine");
System.out.println("==========================================");
System.out.print("\n == Choice: ");
int choice = inputInt.nextInt();
if (choice == 0) {
return false;
}
switch (choice) {
case 1:
if (mtd1) {
System.out.println(" == You have already done breakfast!\n == Going Back.");
continue;
}
System.out.print(" == Input your meal choice: ");
String meal = inputStr.nextLine();
mtd1 = eat(meal);
break;
case 2:
if (mtd2) {
System.out.println(" == You have already done shower!\n == Going Back.");
continue;
}
System.out.print(" == Input your soap choice: ");
String soap = inputStr.nextLine();
System.out.print(" == Input your shampoo choice: ");
String shampoo = inputStr.nextLine();
mtd2 = shower(soap, shampoo);
break;
case 3:
if (mtd3) {
System.out.println(" == You have already done exercise!\n == Going Back.");
continue;
}
System.out.print(" == Input number of sets: ");
int sets = inputInt.nextInt();
mtd3 = exercise(sets);
break;
default:
System.out.println(" == Invalid choice. Please select a valid option.");
showToDo(MorningtoDo);
break;
}
}
return true;
}
public static boolean afternoon(Scanner inputInt, Scanner inputStr) {
String[] todo = { "Eat Lunch", "Take a nap", "Code", "Play Games" };
boolean mtd1 = false;
boolean mtd2 = false;
boolean mtd3 = false;
boolean mtd4 = false;
while (!(mtd1 && mtd2 && mtd3 && mtd4)) {
System.out.println("\nAFTERNOON ROUTINE");
showToDo(todo);
System.out.println("Input 0 to skip afternoon routine");
System.out.println("==========================================");
System.out.print("\n == Choice: ");
int choice = inputInt.nextInt();
if (choice == 0) {
return false;
}
switch (choice) {
case 1:
if (mtd1) {
System.out.println(" == You already had lunch!\n == Going Back.");
continue;
}
System.out.print(" == Input your meal choice: ");
String meal = inputStr.nextLine();
mtd1 = eat(meal);
break;
case 2:
if (mtd2) {
System.out.println(" == You have already taken a nap!\n == Going Back.");
continue;
}
System.out.print(" == Input your nap duration: ");
int minutes = inputInt.nextInt();
mtd2 = nap(minutes);
break;
case 3:
if (mtd3) {
System.out.println(" == You have already done coding!\n == Going Back.");
continue;
}
System.out.print(" == Input number of hours: ");
int hours = inputInt.nextInt();
System.out.print(" == Input language: ");
String language = inputStr.nextLine();
mtd3 = code(hours, language);
break;
case 4:
if (mtd4) {
System.out.println(" == You already played games!\n == Going Back.");
continue;
}
System.out.print(" == Input number of hours: ");
int hours_g = inputInt.nextInt();
System.out.print(" == Input game of choice: ");
String game = inputStr.nextLine();
mtd4 = game(hours_g, game);
break;
default:
System.out.println(" == Invalid choice. Please select a valid option.");
showToDo(todo);
break;
}
}
return true;
}
public static boolean evening(Scanner inputInt, Scanner inputStr) {
String[] todo = { "Dinner", "Half Bath", "Brush Teeth" };
boolean mtd1 = false;
boolean mtd2 = false;
boolean mtd3 = false;
while (!(mtd1 && mtd2 && mtd3)) {
System.out.println("\nEVENING ROUTINE");
showToDo(todo);
System.out.println("Input 0 to skip evening routine");
System.out.println("==========================================");
System.out.print("\nChoice: ");
int choice = inputInt.nextInt();
if (choice == 0) {
return false;
}
switch (choice) {
case 1:
if (mtd1) {
System.out.println(" == You already had Dinner!\n == Going Back.");
continue;
}
System.out.print(" == Input your meal choice: ");
String meal = inputStr.nextLine();
mtd1 = eat(meal);
break;
case 2:
if (mtd2) {
System.out.println(" == You have already taken a half bath!\nGoing Back.");
continue;
}
System.out.print(" == Input your half bath duration: ");
int minutes = inputInt.nextInt();
mtd2 = halfbath(minutes);
break;
case 3:
if (mtd3) {
System.out.println(" == You have already done brushing your teeth!\nGoing Back.");
continue;
}
System.out.print(" == Input choice of toothpaste: ");
String toothpaste = inputStr.nextLine();
mtd3 = brushteeth(toothpaste);
break;
default:
System.out.println(" == Invalid choice. Please select a valid option.");
showToDo(todo);
break;
}
}
return true;
}
public static void main(String[] args) {
System.out.println("Today is Saturday! Ready?");
Scanner inputInt = new Scanner(System.in);
Scanner inputStr = new Scanner(System.in);
boolean morn = morning(inputInt, inputStr);
if (morn) {
System.out.println("\n == YOU HAVE NOW PASSED THE MORNING ROUTINE, CONTINUING TO AFTERNOON ROUTINES ==");
}
boolean af = afternoon(inputInt, inputStr);
if (af) {
System.out.println("\n == YOU HAVE NOW PASSED THE AFTERNOON ROUTINE, CONTINUING TO EVENING ROUTINES == ");
}
evening(inputInt, inputStr);
System.out.println("\n == You have now finished your Saturday! Hope you had a great day!");
inputInt.close();
inputStr.close();
}
}