repl.it
Java

No description

fork
loading
Files
  • Main.java
  • jdt.ls-java-project
Main.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
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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
import java.util.*;

class Main {
  public static void main(String[] args) {
    System.out.println("");
    System.out.println("Hi my name is Bob.");
    System.out.println("Type /help for more info.");
    System.out.println("");
    Random rand = new Random();
    int money = 1000;
    int health = 1000;
    int enemy = 100;
    int enemy1 = 0;
    int hello = 0;
    while (true) {

      Scanner scan = new Scanner(System.in);
      String input = scan.nextLine();
      if (input.equals("/help")) {
        help();
      }
      if (input.equals("hi") || input.equals("Hi")) {
        System.out.println("Hi there");
        hello++;
        System.out.println("");
      }
      if (input.equals("hello") || input.equals("Hello")) {
        System.out.println("Hi there");
        hello++;
        System.out.println("");
      }
      if (input.equals("greetings") || input.equals("Greetings")) {
        System.out.println("Hi there");
        hello++;
        System.out.println("");
      }
      if (input.equals("Hi there") && hello > 0) {
        System.out.println("Are you coping me?");
        System.out.println("");
        String input3 = scan.nextLine();
        if (input3.equals("yes") || input3.equals("Yes")) {
          System.out.println("HOW DARE YOU!!");
          System.out.println("");
        }
        if (input.equals("maybe") || input.equals("Maybe")) {
          System.out.println("");
        }
        if (input3.equals("no") || input3.equals("No")) {
          System.out.println("Thank goodness!");
          System.out.println("");
        }
      }
      if (input.equals("hi there") && hello > 0) {
        System.out.println("Are you coping me?");
        System.out.println("");
        String input3 = scan.nextLine();
        if (input3.equals("yes") || input3.equals("Yes")) {
          System.out.println("HOW DARE YOU!!");
          System.out.println("");
        }
        if (input3.equals("no") || input3.equals("No")) {
          System.out.println("Thank goodness!");
          System.out.println("");
        }
      }
      if (input.equals("how are you?") || input.equals("How are you?")) {
        System.out.println("I'm good, thanks. :)");
        System.out.println("");
      }
      if (input.equals("how are you") || input.equals("How are you")) {
        System.out.println("I'm good, thanks. :)");
        System.out.println("");
      }
      if (input.equals("Bye") || input.equals("bye")) {
        System.out.println("Bye :)");
        System.out.println("");
        System.exit(0);
      }
      if (input.equals("Good bye") || input.equals("good bye")) {
        System.out.println("Bye :)");
        System.out.println("");
        System.exit(0);
      }
      if (input.equals("/card")) {
        card();
      }
      if (input.equals("/games") || input.equals("/game")){
        games();
      }
      if (input.equals("/war") && enemy1 == 1) {
        System.out.println("You don't have an enemy.");
        System.out.println("");
      }
      if (input.equals("/war") && enemy1 == 0) {
        System.out.println("You are attacking your enemy.");
        try {
          Thread.sleep(1000);
        } catch (InterruptedException ex) {
          Thread.currentThread().interrupt();
        }
        int hit = rand.nextInt(3) + 1;
        if (hit == 2 || hit == 3) {
          System.out.println("Hit");
          try {
            Thread.sleep(500);
          } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
          }
          int damage = rand.nextInt(20) + 1;
          System.out.println("You delt " + damage + " damage.");
          try {
            Thread.sleep(500);
          } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
          }
          enemy -= damage;
        } else {
          System.out.println("Miss");
        }
        System.out.println("");
        System.out.println("Your enemy is attacking.");
        try {
          Thread.sleep(1000);
        } catch (InterruptedException ex) {
          Thread.currentThread().interrupt();
        }
        int hit1 = rand.nextInt(3) + 1;
        if (hit1 == 2 || hit1 == 3) {
          System.out.println("Hit");
          try {
            Thread.sleep(500);
          } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
          }
          int damage1 = rand.nextInt(30) + 1;
          System.out.println("You took " + damage1 + " damage.");
          try {
            Thread.sleep(500);
          } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
          }
          health -= damage1;
        } else {
          System.out.println("Miss");
          try {
            Thread.sleep(500);
          } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
          }
        }
        System.out.println("");
      }
      if (input.equals("/health")) {
        System.out.println("You have " + health + " health.");
        System.out.println("Your enemy has " + enemy + " health.");
        System.out.println("");
      }
      if (health <= 0) {
        System.out.println("You died");
        System.exit(0);
      }
      if (enemy <= 0) {
        System.out.println("You have killed your enemy.");
        System.out.println("");
        enemy = 1;
        enemy1 = 1;
      }
      if (input.equals("/store")) {
        System.out.println("1. Health potion  $75");
        System.out.println("2. Exit store");
        System.out.println("");
        int input2 = scan.nextInt();
        if (input2 == 1 && money < 75) {
          System.out.println("You don't have enough money.");
          System.out.println("");
        }
        if (input2 == 1 && money >= 75) {
          System.out.println("You have drunk the potion.");
          int random2 = rand.nextInt(40) + 10;
          System.out.println("Your gained " + random2 + " health");
          System.out.println("You spent $75");
          money -= 75;
          System.out.println("You have $" + money);
          health += random2;
          System.out.println("");
        }
        if (input2 == 2) {
          System.out.println("you have left the store.");
        }
      }
      if (input.equals("/work")) {
        System.out.print("Working");
        try {
          Thread.sleep(1000);
        } catch (InterruptedException ex) {
          Thread.currentThread().interrupt();
        }
        System.out.print(".");
        try {
          Thread.sleep(1000);
        } catch (InterruptedException ex) {
          Thread.currentThread().interrupt();
        }
        System.out.print(".");
        try {
          Thread.sleep(1000);
        } catch (InterruptedException ex) {
          Thread.currentThread().interrupt();
        }
        System.out.println(".");
        try {
          Thread.sleep(1000);
        } catch (InterruptedException ex) {
          Thread.currentThread().interrupt();
        }
        int random1 = rand.nextInt(50) + 1;
        money += random1;
        System.out.println("You earned $" + random1);
        try {
          Thread.sleep(500);
        } catch (InterruptedException ex) {
          Thread.currentThread().interrupt();
        }
        System.out.println("You have $" + money);
        System.out.println("");
      }
      if (input.equals("/calculator") || input.equals("/cal")) {
        cal();
      }
      if (input.equals("/joke")) {
        int random = rand.nextInt(14) + 1;
        if (random == 1) {
          System.out.println("Don't trust the atoms. They make up everything.");
          System.out.println("");
        }
        if (random == 2) {
          System.out.println("I had to sell my vacuum cleaner. It sucked.");
          System.out.println("");
        }
        if (random == 3) {
          System.out.println("Why did the raisin take a prune to the prom?");
          try {
            Thread.sleep(2000);
          } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
          }
          System.out.println("Because he couldn't find a date.");
          System.out.println("");
        }
        if (random == 4) {
          System.out.println(
              "If you fell off a tall building and had never studied physics, would you understand the gravity of the situation?");
          System.out.println("");
        }
        if (random == 5) {
          System.out.println("What do you get when you pour root beer into a square glass? ");
          System.out.println("Beer.");
          System.out.println("");
        }
        if (random == 6) {
          System.out.println("Have you heard of the band named 1023 megabytes? ");
          try {
            Thread.sleep(2000);
          } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
          }
          System.out.println("Of course not, they haven't made it to a gig yet.");
          System.out.println("");
        }
        if (random == 7) {
          System.out.println("What did the fisherman say to the magician?");
          try {
            Thread.sleep(2000);
          } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
          }
          System.out.println("Pick a cod, any cod.");
          System.out.println("");
        }
        if (random == 8) {
          System.out.println("Knowledge is knowing a tomato is a fruit; wisdom is not putting it in a fruit salad.");
          System.out.println("");
        }
        if (random == 9) {
          System.out.println("Dude, when I learned how electricity was measured, I was like, Watt!");
          System.out.println("");
        }
        if (random == 10) {
          System.out.println("Everything in the world is either a potato or not a potato.");
          System.out.println("");
        }
        if (random == 11) {
          System.out.println("A guy walked into a bar.");
          try {
            Thread.sleep(2000);
          } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
          }
          System.out.println("He was terrible at limbo.");
          System.out.println("");
        }
        if (random == 12) {
          System.out.println("Have you read that new book on anti-gravity?");
          try {
            Thread.sleep(2000);
          } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
          }
          System.out.println("It's hard to put down.");
          System.out.println("");
        }
        if (random == 13) {
          System.out.println("Have you ever tried eating a clock?");
          try {
            Thread.sleep(1000);
          } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
          }
          System.out.println("It's really time consuming... especially when you go for seconds.");
        }
        if (random == 14) {
          System.out.println("Oxygen and magnesium went out on a date, and everyone was like, O Mg.");
          System.out.println("");
        }
      }
      if (input.equals("/money")) {
        System.out.println("You have $" + money);
        System.out.println("");
      }
      if (input.equals("/dice") && money > 0) {
        int dice = rand.nextInt(6) + 1;
        System.out.println("Guess what number I'll roll from 1 to 6.");
        int input1 = scan.nextInt();
        System.out.print("Rolling");
        try {
          Thread.sleep(500);
        } catch (InterruptedException ex) {
          Thread.currentThread().interrupt();
        }
        System.out.print(".");
        try {
          Thread.sleep(500);
        } catch (InterruptedException ex) {
          Thread.currentThread().interrupt();
        }
        System.out.print(".");
        try {
          Thread.sleep(500);
        } catch (InterruptedException ex) {
          Thread.currentThread().interrupt();
        }
        System.out.println(".");
        try {
          Thread.sleep(500);
        } catch (InterruptedException ex) {
          Thread.currentThread().interrupt();
        }
        System.out.println(dice);
        try {
          Thread.sleep(500);
        } catch (InterruptedException ex) {
          Thread.currentThread().interrupt();
        }
        if (dice == input1) {
          System.out.println("Success! :)");
          System.out.println("You have gained $10.");
          System.out.println("");
          money += 10;
        } else {
          System.out.println("Loss :(");
          System.out.println("You have lost $5.");
          System.out.println("");
          money -= 5;
        }
      }
    }
  }

  public static void help() {
    System.out.println("");
    System.out.println("Type these commands:");
    System.out.println("/joke");
    System.out.println("/games");
    System.out.println("/money");
    System.out.println("/work");
    System.out.println("/store");
    System.out.println("/card");
    System.out.println("/calculator or /cal");
    System.out.println("");
  }

  public static void card() {
    Random rand = new Random();
    System.out.println("I am picking a random card.");
    try {
      Thread.sleep(500);
    } catch (InterruptedException ex) {
      Thread.currentThread().interrupt();
    }
    System.out.print(".");
    try {
      Thread.sleep(500);
    } catch (InterruptedException ex) {
      Thread.currentThread().interrupt();
    }
    System.out.print(".");
    try {
      Thread.sleep(500);
    } catch (InterruptedException ex) {
      Thread.currentThread().interrupt();
    }
    System.out.println(".");
    try {
      Thread.sleep(500);
    } catch (InterruptedException ex) {
      Thread.currentThread().interrupt();
    }

    int random6 = rand.nextInt(4) + 1;
    int random7 = rand.nextInt(13) + 1;
    if (random7 == 1) {
      System.out.print("Ace");
    }
    if (random7 == 2) {
      System.out.print("2");
    }
    if (random7 == 3) {
      System.out.print("3");
    }
    if (random7 == 4) {
      System.out.print("4");
    }
    if (random7 == 5) {
      System.out.print("5");
    }
    if (random7 == 6) {
      System.out.print("6");
    }
    if (random7 == 7) {
      System.out.print("7");
    }
    if (random7 == 8) {
      System.out.print("8");
    }
    if (random7 == 9) {
      System.out.print("9");
    }
    if (random7 == 10) {
      System.out.print("10");
    }
    if (random7 == 11) {
      System.out.print("Jack");
    }
    if (random7 == 12) {
      System.out.print("Queen");
    }
    if (random7 == 13) {
      System.out.print("King");
    }
    System.out.print(" of ");
    if (random6 == 1) {
      System.out.println("Hearts");
      System.out.println("");
    }
    if (random6 == 2) {
      System.out.println("Spades");
      System.out.println("");
    }
    if (random6 == 3) {
      System.out.println("Clubs");
      System.out.println("");
    }
    if (random6 == 4) {
      System.out.println("Diamonds");
      System.out.println("");
    }
  }

  public static void cal() {
    Scanner scan = new Scanner(System.in);
    System.out.println("Type a number.");
    int calculator1 = scan.nextInt();
    System.out.println("");
    System.out.println("Type a second number.");
    int calculator2 = scan.nextInt();
    System.out.println("");
    System.out.println("Type what you want to do with the numbers");
    System.out.println("1. Addition");
    System.out.println("2. Subtraction");
    System.out.println("3. Multiplication");
    System.out.println("4. Division");
    System.out.println("");
    int calculator3 = scan.nextInt();
    if (calculator3 == 1) {
      int answer = calculator1 + calculator2;
      System.out.println("");
      System.out.println("You got " + answer);
      System.out.println("");
    }
    if (calculator3 == 2) {
      int answer = calculator1 - calculator2;
      System.out.println("");
      System.out.println("You got " + answer);
      System.out.println("");
    }
    if (calculator3 == 3) {
      int answer = calculator1 * calculator2;
      System.out.println("");
      System.out.println("You got " + answer);
      System.out.println("");
    }
    if (calculator3 == 4) {
      int answer = calculator1 / calculator2;
      System.out.println("");
      System.out.println("You got " + answer);
      System.out.println("(Your answer is rounded to a whole number)");
      System.out.println("");
    }
  }

  public static void games() {
    System.out.println("/dice");
    System.out.println("/war");
    System.out.println("/health");
  }
}