-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNewEarth.java
5139 lines (4605 loc) · 177 KB
/
NewEarth.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
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//The Search For New Earth
//By: Skye Chen and Gary Wei
//The "NewEarth" Class
//Start date: May 5, 2017
import java.awt.*;
import java.awt.event.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.*;
import java.io.*;
import java.awt.image.*;
import javax.imageio.*;
import hsa.Console;
public class NewEarth extends Canvas
{
int myX = 300, myY = 300; // Telescope laser location
int celOb1 = (int) (Math.random () * 6 + 1); //random planet selector for level 5
int celOb2 = (int) (Math.random () * 6 + 1);
int celOb3 = (int) (Math.random () * 3 + 1);
static int lev0;
static int lev1;
static int lev2;
static int lev3;
static int lev4;
static int lev5;
static int foundlv2;
static int foundlv3;
static int foundlv4;
static int foundlv5;
static boolean detector;
static boolean found;
Image MillFal = loadImage ("game_images/MillFal.jpg");
Image supernovaImage = loadImage ("game_images/supernova.jpg");
static Console c; // The output console
public static void main (String[] args)
{
c = new Console (30, 100); // pixel border x(0,800), y(0,600)
// Place your program here. 'c' is the output console
double grant = 0; // Currency
Image heli = loadImage ("game_images/helicopter.jpg");
Image err = loadImage ("game_images/ErrorMessage.jpg");
// Use this to draw image:
// c.drawImage (heli, x, y, null);
////////////////////////////////////////////////////////////////////
// Starry background
int[] arrayx = new int [20];
for (int i = 0 ; i <= 19 ; i++)
{
arrayx [i] = (int) (Math.random () * 700);
}
int[] arrayy = new int [20];
for (int i = 0 ; i <= 19 ; i++)
{
arrayy [i] = (int) (Math.random () * 500);
}
for (int flash = 1 ; flash < 6 ; flash++) // TITLE
{
// TITLE
c.setColor (Color.black);
c.fillRect (0, 0, 1000, 1000);
c.setColor (Color.blue);
Font title = new Font ("Comic Sans MS", Font.BOLD, 30);
c.setFont (title);
c.drawString ("THE SEARCH FOR THE NEW EARTH!", 135, 300);
c.setColor (Color.red);
star2 (arrayx, arrayy);
delay (15); // DELAY DEPENDS ON HOW FAST YOUR COMPUTER IS!
c.setColor (Color.black);
c.fillRect (0, 0, 1000, 1000);
c.setColor (Color.blue);
c.setFont (title);
c.drawString ("THE SEARCH FOR THE NEW EARTH!", 135, 300);
c.setColor (Color.red);
star1 (arrayx, arrayy);
delay (15);
c.setColor (Color.black);
c.fillRect (0, 0, 1000, 1000);
c.setColor (Color.blue);
}
int disclaimer = JOptionPane.showConfirmDialog (
null,
"If at any time, the game doesn`t do what you expect it to do, don`t yell at the programmers. Java is just being a little slow, just pause the program and then resume it.",
"DISCLAIMER!!!",
JOptionPane.OK_CANCEL_OPTION);
int skip = JOptionPane.showConfirmDialog (
null,
"Would you like to skip the intro? (If this is your first time, you may want to read it)",
"To skip or not to skip, that is the question",
JOptionPane.YES_NO_OPTION);
if (skip == 1)
{
for (int a = 900 ; a > 100 ; a = a - 2) // Twinkles stars
{ // ^^^Change to 800 if more text is to be added!
c.setColor (Color.black);
c.fillRect (0, 0, 1000, 1000);
if (a % 50 <= 25)
{
c.setColor (Color.red);
star2 (arrayx, arrayy);
}
if (a % 50 >= 25)
{
c.setColor (Color.red);
star1 (arrayx, arrayy);
}
// INTRO
Font intro = new Font ("Comic Sans MS", Font.PLAIN, 18);
c.setFont (intro);
c.setColor (Color.yellow);
c.drawString ("It is the year 2107. Water levels have risen nearly two meters in the past 9 decades", 41, a - 300);
c.drawString ("and they are past the point of no return, with much of the coastlines around the", 62, a - 280);
c.drawString ("world completely submerged. The Global Government realizes the dire situation that", 47, a - 260);
c.drawString ("Planet Earth has been plunged into over the last century and recognizes the need of the", 39, a - 240);
c.drawString ("human race for a new home. As such, the Government has quadrupled the budget for", 50, a - 220);
c.drawString ("space exploration and quintupled the grant money available for research into new", 57, a - 200);
c.drawString ("planets that could possibly be suitable for human inhabitation. You are part of a team", 45, a - 180);
c.drawString ("assembled by Dr. Richard Sun, and your goal is to accumulate enough money for your", 48, a - 160);
c.drawString ("team to carry out their space exploration for a New Earth with the recently-launched", 41, a - 140);
c.drawString ("James Webb VII Space Telescope.", 240, a - 120);
delay (10);
}
c.clear ();
}
c.clear ();
// Choose sex
Frame sex = new Frame ();
JRadioButton male = new JRadioButton ("Male");
JRadioButton female = new JRadioButton ("Female");
JRadioButton other = new JRadioButton ("Other"); //Apache Attack Helicopter
boolean male1, female1, other1, sex1, error;
Color hair = new Color (0, 0, 0);
Color skin = new Color (0, 0, 0);
String message = "What is your sex? (Choose only one)";
Object[] params = {male, female, other};
c.println ("Welcome! Customize your avatar!");
c.println (message);
int n = JOptionPane.showConfirmDialog (sex, params, message, JOptionPane.OK_CANCEL_OPTION);
male1 = male.isSelected ();
female1 = female.isSelected ();
other1 = other.isSelected ();
sex1 = male.isSelected () || female.isSelected () || other.isSelected ();
error = (male1 && female1) || (male1 && other1) || (other1 && female1);
if (error)
{
c.clear ();
c.drawImage (err, 250, 150, null);
c.println ("ERROR! CHOOSE ONLY ONE OPTION PLEASE!");
delay (10);
c.println ("Well, you tried to divide by zero and this is what happened,");
c.println ("You have failed your mission, but feel free to try again!");
delay (10);
c.println ("***TERMINATING***");
delay (1000);
System.exit (0);
}
// Choose Name
c.clear ();
String name;
c.println ("Welcome! What is your name?");
name = c.readLine ();
c.clear ();
// Checks your sex
if (male1)
{
c.println ("Nice to meet you Mr. " + name + "!");
sex1 = male1;
}
else
{
if (female1)
{
c.println ("Nice to meet you Ms. " + name + "!");
sex1 = female1;
}
else
{
other = new JRadioButton ("Other");
c.println ("Nice to meet you other Apache Attack Helicopter Commander " + name + "!");
other1 = true;
sex1 = other1;
}
}
// Displays Silhouette
int a = 375, b = 275; //position of silhouette
c.setColor (Color.black);
avatar (375, 275, sex1, skin, hair, male1, female1, other1, heli);
if (sex1 == other1)
{
}
else
{
// Hair Colour
Frame frame1 = new Frame (); //Blue, Pink, Purple, Brown, Bioluminescent Green
// Needs work on avatar display
JRadioButton blue = new JRadioButton ("Blue");
JRadioButton pink = new JRadioButton ("Pink");
JRadioButton purple = new JRadioButton ("Purple");
JRadioButton brown = new JRadioButton ("Brown");
JRadioButton green = new JRadioButton ("Bioluminescent Green");
boolean blue1, pink1, purple1, brown1, green1;
String message1 = "What is your hair colour? (Choose only one)";
Object[] params1 = {blue, pink, purple, brown, green, other};
c.println (message1);
int n1 = JOptionPane.showConfirmDialog (frame1, params1, message1, JOptionPane.OK_CANCEL_OPTION);
blue1 = blue.isSelected ();
pink1 = pink.isSelected ();
purple1 = purple.isSelected ();
brown1 = brown.isSelected ();
green1 = green.isSelected ();
other1 = other.isSelected ();
error = (blue1 && pink1) || (blue1 && purple1) || (blue1 && brown1) || (blue1 && green1) || (blue1 && other1) || (pink1 && purple1) || (pink1 && brown1) || (pink1 && green1) || (pink1 && other1) || (purple1 && brown1) || (purple1 && green1) || (purple1 && other1) || (brown1 && green1) || (brown1 && other1) || (green1 && other1);
// Conditional statement checks hair colour
c.clear ();
if (error)
{
c.clear ();
c.drawImage (err, 250, 150, null);
c.println ("ERROR! CHOOSE ONLY ONE OPTION PLEASE!");
delay (10);
c.println ("Well " + name + ", you tried to divide by zero and this is what happened,");
c.println ("You have failed your mission, but feel free to try again!");
delay (10);
c.println ("***TERMINATING***");
delay (1000);
System.exit (0);
}
else if (blue1)
{
hair = new Color (0, 0, 255);
}
else if (pink1)
{
hair = new Color (255, 192, 203);
}
else if (purple1)
{
hair = new Color (128, 0, 128);
}
else if (brown1)
{
hair = new Color (139, 69, 19);
}
else if (green1)
{
hair = new Color (0, 255, 0);
}
else // Cancel + other
{
hair = new Color (255, 255, 255);
other = new JRadioButton ("Other");
c.println ("Hello baldie! You found an Easter Egg!");
}
avatar (375, 275, sex1, skin, hair, male1, female1, other1, heli);
delay (1);
//Skin colour (Red, Blue, Green) {Easter Egg; BGR Input = White)
Frame frame2 = new Frame (); // Accidentally pasted hair into skin
JRadioButton redS = new JRadioButton ("Red");
JRadioButton blueS = new JRadioButton ("Blue");
JRadioButton greenS = new JRadioButton ("Green");
boolean redS1, blueS1, greenS1, all;
String mess2 = "What is your skin colour? (Choose only one)";
Object[] params2 = {redS, blueS, greenS};
c.println (mess2);
int n2 = JOptionPane.showConfirmDialog (frame2, params2, mess2, JOptionPane.OK_CANCEL_OPTION);
redS1 = redS.isSelected ();
blueS1 = blueS.isSelected ();
greenS1 = greenS.isSelected ();
error = (redS1 && blueS1) || (redS1 && greenS1) || (blueS1 && greenS1);
all = redS1 && blueS1 && greenS1;
c.clear ();
if (all)
{
c.println ("You chose a white!");
c.println ("You found an Easter egg!");
skin = new Color (250, 250, 250);
}
else
{
if (error)
{
c.clear ();
c.drawImage (err, 250, 150, null);
c.println ("ERROR! CHOOSE ONLY ONE OPTION PLEASE!");
delay (10);
c.println ("Well " + name + ", you tried to divide by zero and this is what happened,");
c.println ("You have failed your mission, but feel free to try again!");
delay (10);
c.println ("***TERMINATING***");
delay (1000);
System.exit (0);
}
else
{
if (redS1)
{
skin = new Color (255, 0, 0);
}
else
{
if (blueS1)
{
skin = new Color (0, 0, 255);
}
else
{
if (greenS1)
{
skin = new Color (0, 255, 0);
}
else // Cancel
{
c.println ("You chose a white!");
c.println ("You found an Easter egg!");
skin = new Color (250, 250, 250);
}
}
}
}
}
avatar (375, 275, sex1, skin, hair, male1, female1, other1, heli);
delay (1);
}
c.println ("Nice to meet you " + name + "! Well, let's get started; you need to collect enough grant money ($10000)");
c.println ("to fund your team's search for a New Earth and for that you will need to win 5 grants.");
String key;
c.print ("Input any key to continue then press <Enter>: ");
key = c.readString ();
c.clear ();
if (sex1 == male1)
{
male (a, b, skin, hair);
}
else if (sex1 == female1)
{
female (a, b, skin, hair);
}
else if (sex1 == other1)
{
c.drawImage (heli, 275, 300, null); // DISPLAY HELICOPTER HERE!
}
else
{
c.drawImage (heli, 275, 300, null); // DISPLAY HELICOPTER HERE!
}
c.println ("Here's the first grant opportunity (tutorial/Level 0):");
c.println ("Find a celestial body in this patch of the night sky! You can change the");
c.println ("trajectory of the telescope with your arrow keys or WASD keys. Give it a try, and");
c.println ("find one planet, or star.");
c.println ("Use the WASD keys for a slow and thorough scan or use the Arrow keys for a fast scan");
c.println ("Your laser beam and crosshair will change from white, to yellow, to orange, and then red as you get");
c.println ("closer to a celestial object. AND IF ANY ONE ASKS, THIS IS THE TEXT CONSOLE!");
c.println ("(Hint: do a quick scan in the tutorial) When you are done reading, input any key and press <Enter>: ");
key = c.readString ();
// First mission!
for (found = false ; found == false ;)
{
lev0 = 1;
JFrame tutorial = new JFrame ("Tutorial Level 0");
tutorial.setDefaultCloseOperation (JFrame.DISPOSE_ON_CLOSE);
NewEarth ex = new NewEarth ();
tutorial.getContentPane ().add (ex);
tutorial.pack ();
tutorial.setResizable (false);
tutorial.setVisible (true);
ex.requestFocus ();
int warning = JOptionPane.showConfirmDialog (
null,
"Please do not drag any of the console screens around, only click back and forth between them!",
"WARNING!!!",
JOptionPane.OK_CANCEL_OPTION);
c.println ("Don't type in any key nor <Enter> until you found a celestial body!");
c.readString ();
} //End of first missioni
for (boolean tutorialID = false ; tutorialID == false ;) //tutorial lv. classification database
{
for (boolean exit = false ; exit == false ;) //NEIL DEGRASS TYSON DATABASE
{
avatar (375, 275, sex1, skin, hair, male1, female1, other1, heli);
String objectFound = "";
c.clear ();
// int noti = JOptionPane.showConfirmDialog (
// null,
// "The programmers regret to inform you the user that the game is buggy if you leave the game console on. So write down/memorize/take a picture of the planets info and then close it.",
// "Notification!",
// JOptionPane.OK_CANCEL_OPTION);
c.println ("Welcome to the Neil DeGrasse Tyson celestial object data base,");
c.println ("Feel free to exit when you think you have made a positive identification");
c.println ("or choose ONE of the following to find out more:");
Frame Legend = new Frame ();
JRadioButton Planet = new JRadioButton ("Planets");
JRadioButton Star = new JRadioButton ("Stars");
JRadioButton Others = new JRadioButton ("Other celestial objects");
JRadioButton Exit = new JRadioButton ("Exit the NDGT database");
boolean Planet1, Star1, Others1, Exit1, errorLegend;
String messageLegend = "Which category would you like to learn more about " + name + "?";
c.println ();
c.println (messageLegend);
Object[] paramsLegend = {Planet, Star, Others, Exit};
int category = JOptionPane.showConfirmDialog (Legend, paramsLegend, messageLegend, JOptionPane.OK_CANCEL_OPTION);
Planet1 = Planet.isSelected ();
Star1 = Star.isSelected ();
Others1 = Others.isSelected ();
Exit1 = Exit.isSelected ();
errorLegend = ((Planet1 & Star1) || (Planet1 && Others1) || (Star1 && Others1) || (Planet1 && Exit1) || (Star1 && Exit1) || (Others1 && Exit1));
if (errorLegend)
{
c.clear ();
c.drawImage (err, 250, 150, null);
c.println ("ERROR! CHOOSE ONLY ONE OPTION PLEASE!");
delay (10);
c.println ("Well " + name + ", you tried to divide by zero and this is what happened,");
c.println ("You have failed your mission, but feel free to try again!");
delay (10);
c.println ("***TERMINATING***");
delay (1000);
System.exit (0);
}
else if (Planet1)
{
objectFound = "Planets";
}
else if (Star1)
{
objectFound = "Stars";
}
else if (Others1)
{
objectFound = "Others";
}
else
{
exit = true;
}
legend (objectFound);
} // end of level tutorial database
//{<DON'T REMOVE //! Start of level tutorial classification
c.println ("Thank you for using the Neil DeGrasse Tyson celestial object data base.");
c.println ("Now you must properly identify what that celestial object was.");
c.println ("Choose only ONE option please!");
c.println ();
c.println ("Just choose whether your newly - discovered space - thing is a planetary body, a");
c.println ("star, or something else! Then you can further specify what exactly your");
c.println ("space - thing is. At the end of the classification window, you can confirm your");
c.println ("classification. But be careful - even though you get reward money from the");
c.println ("Global Government for correctly classifying a celestial object, the AstroPhysical");
c.println ("Society of Earth (APSE) will dock your pay each time you incorrectly classify a");
c.println ("space - thing! Not to mention they 'll mock your scientific prowess while haughtily");
c.println ("stroking their science - beards.");
Frame tutorialObject = new Frame (); // Quiz for tutorial pt. 1
JRadioButton Planet = new JRadioButton ("A Planet");
JRadioButton Star = new JRadioButton ("A Star");
JRadioButton Others = new JRadioButton ("Other celestial objects");
boolean Planet1, Star1, Others1, errorTutorial;
String messageTutorial = "Which celestial body do you think this is " + name + "?";
c.println ();
c.println (messageTutorial);
Object[] paramsTutorial = {Planet, Star, Others};
for (boolean affirm = false ; affirm == false ;)
{
int category = JOptionPane.showConfirmDialog (tutorialObject, paramsTutorial, messageTutorial, JOptionPane.OK_CANCEL_OPTION);
int confirm = JOptionPane.showConfirmDialog (
null,
"Remember " + name + ", you will lose grant money if you get this wrong! And for your own sake, go back if you chose more than 1 answer, the APSE doesn't like uncertainty!",
"ARE YOU SURE???!!!",
JOptionPane.YES_NO_OPTION);
if (confirm == JOptionPane.YES_OPTION)
{
affirm = true;
}
else
{
affirm = false;
}
}
Planet1 = Planet.isSelected ();
Star1 = Star.isSelected ();
Others1 = Others.isSelected ();
errorTutorial = ((Planet1 & Star1) || (Planet1 && Others1) || (Star1 && Others1));
if (errorTutorial)
{
c.clear ();
c.drawImage (err, 250, 150, null);
c.println ("ERROR! CHOOSE ONLY ONE OPTION PLEASE!");
delay (10);
c.println ("Well " + name + ", you tried to divide by zero and this is what happened,");
c.println ("You have failed your mission, but feel free to try again!");
delay (10);
c.println ("***TERMINATING***");
delay (1000);
System.exit (0);
}
else if (Planet1)
{
Frame planets = new Frame (); //Quiz for tutorial pt. 2
JRadioButton Earth = new JRadioButton ("Earth-like");
JRadioButton SuperEarth = new JRadioButton ("Super Earth");
JRadioButton IceGiant = new JRadioButton ("Ice Giant");
JRadioButton GasGiant = new JRadioButton ("Gas Giant");
boolean Earth1, SuperEarth1, IceGiant1, GasGiant1, errorPlanets;
String messagePlanets = "Which planet type do you think this is " + name + "?";
c.println ();
c.println (messagePlanets);
Object[] paramsPlanets = {Earth, SuperEarth, IceGiant, GasGiant};
for (boolean affirm = false ; affirm == false ;)
{
int planetQuiz = JOptionPane.showConfirmDialog (planets, paramsPlanets, messagePlanets, JOptionPane.OK_CANCEL_OPTION);
int confirm = JOptionPane.showConfirmDialog (
null,
"Remember " + name + ", you will lose grant money if you get this wrong! And for your own sake, go back if you chose more than 1 answer, the APSE doesn't like uncertainty!",
"ARE YOU SURE???!!!",
JOptionPane.YES_NO_OPTION);
if (confirm == JOptionPane.YES_OPTION)
{
affirm = true;
}
else
{
affirm = false;
}
}
Earth1 = Earth.isSelected ();
SuperEarth1 = SuperEarth.isSelected ();
IceGiant1 = IceGiant.isSelected ();
GasGiant1 = GasGiant.isSelected ();
errorPlanets = ((Earth1 && SuperEarth1) || (Earth1 && IceGiant1) || (Earth1 && GasGiant1) || (SuperEarth1 && IceGiant1) || (SuperEarth1 && GasGiant1) || (IceGiant1 && GasGiant1));
if (errorPlanets)
{
c.clear ();
c.drawImage (err, 250, 150, null);
c.println ("ERROR! CHOOSE ONLY ONE OPTION PLEASE!");
delay (10);
c.println ("Well " + name + ", you tried to divide by zero and this is what happened,");
c.println ("You have failed your mission, but feel free to try again!");
delay (10);
c.println ("***TERMINATING***");
delay (1000);
System.exit (0);
}
else if (SuperEarth1)
{
tutorialID = true;
}
else
{
c.println ("NOPE! The APSE board members make snide remarks about your mother! ");
c.println ("Minus 3 dignity points :( How about you go out there and try it again?");
c.println ("Since this is the tutorial, the ASPE has decided not to deduct money from you");
c.println ("You may want to consult the Neil DeGrasse Tyson database again...");
c.print ("Press any key and then <Enter> to continue: ");
c.readString ();
}
}
else
{
c.println ("NOPE! The APSE board members make snide remarks about your mother! ");
c.println ("Minus 3 dignity points :( How about you go out there and try it again?");
c.println ("Since this is the tutorial, the ASPE has decided not to deduct money from you");
c.println ("You may want to consult the Neil DeGrasse Tyson database again...");
c.print ("Press any key and then <Enter> to continue: ");
c.readString ();
}
}
String tutorialName;
grant = grant + 1000;
c.clear ();
avatar (375, 275, sex1, skin, hair, male1, female1, other1, heli);
c.println ("Good job " + name + "! You got ($1000) for that correct classification of a Super Earth Planet");
c.print ("Your balance is now $");
c.print (grant, 0, 2);
c.print (" Go ahead, name the planet: "); //Space here is for grant
tutorialName = c.readLine ();
c.clear ();
c.println ("You have named the Super Earth Planet \"" + tutorialName + "\"! Now you're ready to go out ");
c.print ("there and do some space-searching! Press any key then <Enter> to continue: ");
c.readString ();
found = false;
//}<DON'T REMOVE //! end of level tutorial classification
for (found = false ; found == false ;) //LEVEL 1
{
lev1 = 1;
JFrame level1 = new JFrame ("Level 1");
level1.setDefaultCloseOperation (JFrame.DISPOSE_ON_CLOSE);
NewEarth ex = new NewEarth ();
level1.getContentPane ().add (ex);
level1.pack ();
level1.setResizable (false);
level1.setVisible (true);
ex.requestFocus ();
int warning = JOptionPane.showConfirmDialog (
null,
"Remember, please do not drag any of the console screens around, only click back and forth between them!",
"WARNING!!!",
JOptionPane.OK_CANCEL_OPTION);
c.println ("Don't type in any key nor <Enter> until you found a celestial body!");
c.readString ();
} // end of level 1
for (boolean Level1ID = false ; Level1ID == false ;) //First lv. classification database
{
for (boolean exit = false ; exit == false ;) //NEIL DEGRASS TYSON DATABASE
{
avatar (375, 275, sex1, skin, hair, male1, female1, other1, heli);
String objectFound = "";
c.clear ();
c.println ("Welcome to the Neil DeGrasse Tyson celestial object data base,");
c.println ("Feel free to exit when you think you have made a positive identification");
c.println ("or choose ONE of the following to find out more:");
Frame Legend = new Frame ();
JRadioButton Planet = new JRadioButton ("Planets");
JRadioButton Star = new JRadioButton ("Stars");
JRadioButton Others = new JRadioButton ("Other celestial objects");
JRadioButton Exit = new JRadioButton ("Exit the NDGT database");
boolean Planet1, Star1, Others1, Exit1, errorLegend;
String messageLegend = "Which category would you like to learn more about " + name + "?";
c.println ();
c.println (messageLegend);
Object[] paramsLegend = {Planet, Star, Others, Exit};
int category = JOptionPane.showConfirmDialog (Legend, paramsLegend, messageLegend, JOptionPane.OK_CANCEL_OPTION);
Planet1 = Planet.isSelected ();
Star1 = Star.isSelected ();
Others1 = Others.isSelected ();
Exit1 = Exit.isSelected ();
errorLegend = ((Planet1 & Star1) || (Planet1 && Others1) || (Star1 && Others1) || (Planet1 && Exit1) || (Star1 && Exit1) || (Others1 && Exit1));
if (errorLegend)
{
c.clear ();
c.drawImage (err, 250, 150, null);
c.println ("ERROR! CHOOSE ONLY ONE OPTION PLEASE!");
delay (10);
c.println ("Well " + name + ", you tried to divide by zero and this is what happened,");
c.println ("You have failed your mission, but feel free to try again!");
delay (10);
c.println ("***TERMINATING***");
delay (1000);
System.exit (0);
}
else if (Planet1)
{
objectFound = "Planets";
}
else if (Star1)
{
objectFound = "Stars";
}
else if (Others1)
{
objectFound = "Others";
}
else
{
exit = true;
}
legend (objectFound);
} // end of level 1 database
//{<DON'T REMOVE //! Start of level 1 classification
c.println ("Thank you for using the Neil DeGrasse Tyson celestial object data base.");
c.println ("Now you must properly identify what that celestial object was.");
c.println ("Choose only ONE option please!");
c.println ();
Frame Level1Object = new Frame (); // Quiz for level 1 pt. 1
JRadioButton Planet = new JRadioButton ("A Planet");
JRadioButton Star = new JRadioButton ("A Star");
JRadioButton Others = new JRadioButton ("Other celestial objects");
boolean Planet1, Star1, Others1, errorLevel1;
String messageLevel1 = "Which celestial body do you think this is " + name + "?";
c.println ();
c.println (messageLevel1);
Object[] paramsLevel1 = {Planet, Star, Others};
for (boolean affirm = false ; affirm == false ;)
{
int category = JOptionPane.showConfirmDialog (Level1Object, paramsLevel1, messageLevel1, JOptionPane.OK_CANCEL_OPTION);
int confirm = JOptionPane.showConfirmDialog (
null,
"Remember " + name + ", you will lose grant money if you get this wrong! And for your own sake, go back if you chose more than 1 answer, the APSE doesn't like uncertainty!",
"ARE YOU SURE???!!!",
JOptionPane.YES_NO_OPTION);
if (confirm == JOptionPane.YES_OPTION)
{
affirm = true;
}
else
{
affirm = false;
}
}
Planet1 = Planet.isSelected ();
Star1 = Star.isSelected ();
Others1 = Others.isSelected ();
errorLevel1 = ((Planet1 & Star1) || (Planet1 && Others1) || (Star1 && Others1));
if (errorLevel1)
{
c.clear ();
c.drawImage (err, 250, 150, null);
c.println ("ERROR! CHOOSE ONLY ONE OPTION PLEASE!");
delay (10);
c.println ("Well " + name + ", you tried to divide by zero and this is what happened,");
c.println ("You have failed your mission, but feel free to try again!");
delay (10);
c.println ("***TERMINATING***");
delay (1000);
System.exit (0);
}
else if (Planet1)
{
Frame planets = new Frame (); //Quiz for level 1 pt. 2
JRadioButton Earth = new JRadioButton ("Earth-like");
JRadioButton SuperEarth = new JRadioButton ("Super Earth");
JRadioButton IceGiant = new JRadioButton ("Ice Giant");
JRadioButton GasGiant = new JRadioButton ("Gas Giant");
boolean Earth1, SuperEarth1, IceGiant1, GasGiant1, errorPlanets;
String messagePlanets = "Which planet type do you think this is " + name + "?";
c.println ();
c.println (messagePlanets);
Object[] paramsPlanets = {Earth, SuperEarth, IceGiant, GasGiant};
for (boolean affirm = false ; affirm == false ;)
{
int planetQuiz = JOptionPane.showConfirmDialog (planets, paramsPlanets, messagePlanets, JOptionPane.OK_CANCEL_OPTION);
int confirm = JOptionPane.showConfirmDialog (
null,
"Remember " + name + ", you will lose grant money if you get this wrong! And for your own sake, go back if you chose more than 1 answer, the APSE doesn't like uncertainty!",
"ARE YOU SURE???!!!",
JOptionPane.YES_NO_OPTION);
if (confirm == JOptionPane.YES_OPTION)
{
affirm = true;
}
else
{
affirm = false;
}
}
Earth1 = Earth.isSelected ();
SuperEarth1 = SuperEarth.isSelected ();
IceGiant1 = IceGiant.isSelected ();
GasGiant1 = GasGiant.isSelected ();
errorPlanets = ((Earth1 && SuperEarth1) || (Earth1 && IceGiant1) || (Earth1 && GasGiant1) || (SuperEarth1 && IceGiant1) || (SuperEarth1 && GasGiant1) || (IceGiant1 && GasGiant1));
if (errorPlanets)
{
c.clear ();
c.drawImage (err, 250, 150, null);
c.println ("ERROR! CHOOSE ONLY ONE OPTION PLEASE!");
delay (10);
c.println ("Well " + name + ", you tried to divide by zero and this is what happened,");
c.println ("You have failed your mission, but feel free to try again!");
delay (10);
c.println ("***TERMINATING***");
delay (1000);
System.exit (0);
}
else if (IceGiant1)
{
Level1ID = true;
}
else
{
c.println ("NOPE! The APSE board members mock your brain size! Minus 3 ");
c.println ("dignity points. Also, they docked $100 from your pay! :( How about");
grant = grant - 100;
c.println ("Your balance is now $" + grant + ". Now you go out there and try it again!");
c.println ("You may want to consult the Neil DeGrasse Tyson database again...");
c.print ("Press any key and then <Enter> to continue: ");
c.readString ();
if (grant < 0)
{
c.clear ();
c.drawImage (err, 250, 150, null);
c.println ("YOUR COMPANY IS IN DEBT!");
delay (10);
c.println ("Well, you tried to square root a negative number, and this is what happened.");
c.println ("You have failed your mission, but feel free to try again!");
delay (10);
c.println ("***TERMINATING***");
delay (1000);
System.exit (0);
}
}
}
else
{
c.println ("NOPE! The APSE board members mock your brain size! Minus 3 ");
c.println ("dignity points. Also, they docked $100 from your pay! :( How about");
grant = grant - 100;
c.println ("Your balance is now $" + grant + ". Now you go out there and try it again!");
c.println ("You may want to consult the Neil DeGrasse Tyson database again...");
c.print ("Press any key and then <Enter> to continue: ");
c.readString ();
if (grant < 0)
{
c.clear ();
c.drawImage (err, 250, 150, null);
c.println ("YOUR COMPANY IS IN DEBT!");
delay (10);
c.println ("Well, you tried to square root a negative number, and this is what happened.");
c.println ("You have failed your mission, but feel free to try again!");
delay (10);
c.println ("***TERMINATING***");
delay (1000);
System.exit (0);
}
}
}
String Level1Name;
grant = grant + 1500;
c.clear ();
avatar (375, 275, sex1, skin, hair, male1, female1, other1, heli);
c.println ("Good job! You got ($1500) for that correct classification of an Ice Giant Planet!");
c.print ("Your balance is now $");
c.print (grant, 0, 2);
c.print (" Go ahead, name the planet: "); //Space here is for grant
Level1Name = c.readLine ();
c.clear ();
c.println ("You have named the Ice Giant Planet \"" + Level1Name + "\"! Now you're ready to go out ");
c.print ("there and do some more space-searching! Press any key then <Enter> to continue: ");
c.readString ();
found = false;
//}< DON'T REMOVE end of lv. 1 classification
for (found = false ; found == false ;) //LEVEL 2
{
lev2 = 1;
JFrame level2 = new JFrame ("Level 2");
level2.setDefaultCloseOperation (JFrame.DISPOSE_ON_CLOSE);
NewEarth ex = new NewEarth ();
level2.getContentPane ().add (ex);
level2.pack ();
level2.setResizable (false);
level2.setVisible (true);
ex.requestFocus ();
c.println ("Don't type in any key nor <Enter> until you found a celestial body!");
c.readString ();
} // end of level 2
//Level 2 classifying process
for (boolean level2ID = false ; level2ID == false ;)
{
for (boolean exit = false ; exit == false ;) //NEIL DEGRASS TYSON DATABASE
{
avatar (375, 275, sex1, skin, hair, male1, female1, other1, heli);
String objectFound = "";
c.clear ();
c.println ("Welcome to the Neil DeGrasse Tyson celestial object data base,");
c.println ("Feel free to exit when you think you have made a positive identification");
c.println ("or choose ONE of the following to find out more:");
Frame Legend = new Frame ();
JRadioButton Planet = new JRadioButton ("Planets");
JRadioButton Star = new JRadioButton ("Stars");
JRadioButton Others = new JRadioButton ("Other celestial objects");
JRadioButton Exit = new JRadioButton ("Exit the NDGT database");
boolean Planet1, Star1, Others1, Exit1, errorLegend;
String messageLegend = "Which category would you like to learn more about " + name + "?";
c.println ();
c.println (messageLegend);
Object[] paramsLegend = {Planet, Star, Others, Exit};
int category = JOptionPane.showConfirmDialog (Legend, paramsLegend, messageLegend, JOptionPane.OK_CANCEL_OPTION);
Planet1 = Planet.isSelected ();
Star1 = Star.isSelected ();
Others1 = Others.isSelected ();
Exit1 = Exit.isSelected ();
errorLegend = ((Planet1 & Star1) || (Planet1 && Others1) || (Star1 && Others1) || (Planet1 && Exit1) || (Star1 && Exit1) || (Others1 && Exit1));
if (errorLegend)
{
c.clear ();
c.drawImage (err, 250, 150, null);
c.println ("ERROR! CHOOSE ONLY ONE OPTION PLEASE!");
delay (10);
c.println ("Well " + name + ", you tried to divide by zero and this is what happened,");
c.println ("You have failed your mission, but feel free to try again!");
delay (10);
c.println ("***TERMINATING***");
delay (1000);
System.exit (0);
}
else if (Planet1)
{
objectFound = "Planets";
}
else if (Star1)
{