-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.java
More file actions
executable file
·111 lines (97 loc) · 3.43 KB
/
Copy pathmain.java
File metadata and controls
executable file
·111 lines (97 loc) · 3.43 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
import java.util.*;
class Main {
public static void main(String[] args) {
UserInterface ui = new UserInterface();
Crew crew1 = new Crew();
TextBlocks text = new TextBlocks();
Weather weather = new Weather();
Scanner keyboard = new Scanner(System.in);
Supplies supplies = new Supplies();
Supplies.Food food;
Supplies.Fuel fuel;
Supplies.Water water;
Supplies.SpaceSuits spacesuits;
Supplies.SpareParts spareparts;
// Start up game
text.printGameGreetings();
String captainName = "Captain " + keyboard.next();
text.printWelcomeMessage(captainName);
text.pressEnter();
ui.clear();
// Give Space Craft options
text.printAllCraftSpecs();
int userChoice = keyboard.nextInt();
int userChoice2 = 0;
// Buy Space Craft
SpaceCraft firstCraft = text.getCraft(userChoice); // terrible locations for that method
userChoice = 0; // reset userChoice
ui.clear();
// Hire Crew
text.printCrewPrompt();
int canHire = firstCraft.getCapacity() - 1;
while (userChoice != 5) {
text.printCrewOptions();
ui.println("You can hire "+ canHire + " crew members.");
userChoice = keyboard.nextInt();
if (userChoice != 5) {
ui.print("Great. How many would you like to hire? ");
userChoice2 = keyboard.nextInt();
if (userChoice2 > canHire) {
ui.println("I'm sorry. You can't hire that many.");
} else if (userChoice2 < 1) {
ui.println("I'm sorry. You can't hire that number.");
} else {
crew1.modifyCrew((userChoice-1), userChoice2);
}
} else if (canHire == (firstCraft.getCapacity() - 1)){
ui.println("You haven't added any crew. Are you sure you want to exit?\n1. Yes\n2. No");
userChoice = keyboard.nextInt();
if (userChoice != 1) {
userChoice = 0;
} else {
userChoice = 5;
}
}
canHire -= userChoice2;
}
crew1.printCrewList();
text.pressEnter();
// Initial Supply Purchase
text.printFirstSupplyPurchase();
text.purchaseFoodDialogue();
food = new Supplies.Food(Supplies.Food.foodRationSize.FILLING, keyboard.nextInt());
text.purchaseWaterDialogue();
water = new Supplies.Water(Supplies.Water.waterRationSize.HYDRATED, keyboard.nextInt());
//text.purchaseFuelDialogue();
//fuel = new Supplies.Fuel(Supplies.Fuel.fuelTankSize.MEDIUM, keyboard.nextInt());
// Launch Sequence
userChoice = 0;
int launchCounter = 1;
text.printLaunchIntro();
Cloud currentCloud = weather.establishCloudForecast();
Wind currentWind = weather.establishWindForecast();
Rain currentRain = weather.establishRainForecast();
while (userChoice != 2 && launchCounter < 15) {
// New Day's Weather
currentCloud = weather.establishCloudForecast();
currentWind = weather.establishWindForecast();
currentRain = weather.establishRainForecast();
text.printLaunchForecast(launchCounter);
weather.printWeatherForecast(currentRain, currentCloud, currentWind);
launchCounter++;
text.printLaunchOptions();
userChoice = keyboard.nextInt();
}
if (launchCounter > 14) {
ui.println("You postponed the launch too long and missed your launch window! It takes time for multiple planetary orbits to align, you know!");
} else if (weather.willLaunchSucceed(currentRain.getRiskFactor(), currentCloud.getRiskFactor(), currentWind.getRiskFactor())) {
ui.println("Congrats. The launch was successful.");
} else {
ui.println("u ded.");
}
int daysCounter = 1;
userChoice = 0;
userChoice2 = 0;
boolean isAlive = true; // player state
}
}