-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPuzzle.java
More file actions
254 lines (209 loc) · 7.23 KB
/
Puzzle.java
File metadata and controls
254 lines (209 loc) · 7.23 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
import java.util.Scanner;
/**
* Class: Puzzle
*
* @author Valentin Meica
* @version 1.0 Course : Software Development I Section 01 Spring 2015 Written:
* April 10, 2015
*
*
* This class � a pattern class for puzzle
*
* Purpose: � a puzzle for a text game.
*/
// 7 descriptins and 7 methods
public class Puzzle {
// Player user = new Player("John");
public static final String LIGHT_COMBINATION = "\nMatch the color scheme "
+ "\nstraight on.\nPlease separate your answers by comma."
+ "\n[1] BLUE, BLUE, AQUA, GREEN, PURPLE, GREEN"
+ "\n[2] BLUE, AQUA, BLUE, GREEN, PURPLE, PURPLE";
public static final String ALIEN_NECKLACE = "Your task is to find all 3 "
+ "\npieces of a necklace.\n[1] CONTINUE ON";
public static final String BUTTON_HANDLE = "You have a choice:"
+ "\n[1] PULL HANDLE\n[2] PUSH BUTTON";
public static final String ENTRANCE_CHOICE = "You are facing four doors, "
+ "\nchoose an entrance. Beware only one door leads to the next chamber!"
+ "\n[1] DOOR ONE\n[2] DOOR TWO\n[3] DOOR THREE\n[4] DOOR FOUR";
public static final String MEMORIZATION = "Remember what was the answers to "
+ "\nthe questions earlier and write them on the cage"
+ "\n[1] DINORNIS ROBUSTUS AND BREATH" // WRONG you end up being
// eaten by Jack
+ "\n[2] SMOKE AND GRAVITY" // WRONG you end up being eaten by Jack
+ "\n[3] BREATH AND SMOKE"; // Yay! The cage opens
public static final String RIDDLE = "Comes face to face with the light. The "
+ "\nlight shatters and the room begins to close in on you. The pieces "
+ "\nof light surround you and then move in front of you. A message of "
+ "\nlight begins to appear and the message turns out to be a riddle. "
+ "\nI\'m light as a feather, yet the strongest man can't hold me for "
+ "\nmuch more than a minute. What am I?" + "\n[1] BREATH" // Moves
// on to
// the
// next
// riddle
+ "\n[2] GRAVITY" // WRONG so you die
+ "\n[3] ANT"; // WRONG so you die
public static final String RIDDLE2 = "Wise choice! Second Riddle: I am the "
+ "\nblack child of a white father, a wingless bird, flying even to the "
+ "\nclouds of heaven. I give birth to tears of mourning in pupils that "
+ "\nmeet me, even though there is no cause for grief, and at once on "
+ "\nmy birth I am dissolved into air. What am I?" + "\n[1] GHOST" // WRONG
// you
// die
+ "\n[2] SMOKE" // Right! Continue on
+ "\n[3] DINORNIS ROBUSTUS"; // WRONG you die
public static final String TRIPLERIDDLE1 = "The alien informs you that he is "
+ "\nnot there to eat him but will whenever the player gets a wrong "
+ "\nanswer. What lives in winter, dies in summer, and grows with its "
+ "\nroot upward?" + "\n[1] ICE" // WRONG
+ "\n[2] AN ICICLE" // RIGHT
+ "\n[3] A SNOWMAN"; // WRONG
public static final String TRIPLERIDDLE2 = "What three letters mean 'stiff water'?"
+ "\n[1] ICE" // RIGHT
+ "\n[2] FROZEN" // WRONG
+ "\n[3] I.C.E "; // WRONG
public static final String TRIPLERIDDLE3 = "What runs but never gets tired?"
+ "\n[1] THE ROADRUNNER" // WRONG
+ "\n[2] AN INTERGALACTIC SPACE DEVIL" // WRONG
+ "\n[3] WATER"; // RIGHT
/**
* Method: solvingPuzzle if the user enters the right combination of colors,
* otherwise try again
*
* @return boolean
**/
public static boolean solvingLightCombination(String userInput) {
boolean solved = false;
if (userInput.equalsIgnoreCase("1")) {
System.out.println("The door opens. Well Done!");
solved = true;
} else {
System.out.println("Wrong combination please try again.");
solved = false;
}
return solved;
}
/**
* Method: solvingPuzzle checks what choice the user makes and provides an
* output
*
* @return boolean
**/
public static boolean solvingButtonHandle(String userInput) {
boolean solved = false;
if (userInput.equalsIgnoreCase("1")) { // go to the room
solved = true;
System.out.println("Proceed to the next room.");
} else if (userInput.equalsIgnoreCase("2")) {
// go to the other room
System.out.println("Nothing happens try something else.");
solved = true;
}
return solved;
}
/**
* Method: solvingPuzzle if the user enters the right door puzzle solved
* otherwise try again
*
* @return boolean
**/
public boolean solvingEntranceChoice(String userInput) {
boolean solved = false;
if (userInput.equalsIgnoreCase("1")) {
System.out.println("Puzzle solved!");
solved = true;
} else {
System.out.println("Failed try again.");
solved = false;
}
return solved;
}
/**
* Method: solvingPuzzle if the user enters the right combination that was
* the answers to the riddle puzzle
*
* @return boolean
**/
public static boolean solvingMemorization(String userInput) {
boolean solved = false;
if (userInput.equalsIgnoreCase("3")) {
System.out.println("That is correct, the cage opens!");
solved = true;
} else {
System.out.println("Jack grabs you and eats you.");
// user.setHealthpoints(0);
solved = false;
}
return solved;
}
/**
* Method: solvingPuzzle if the user enters the wrong answer he is being
* eaten by monster.
*
* @return boolean
**/
public static boolean solvingRiddle(String userInput) {
boolean solved = false;
if (userInput.equalsIgnoreCase("1")) // 1 is for breath
{
System.out.println(RIDDLE2);
Scanner input = new Scanner(System.in);
userInput = input.next();
if (userInput.equalsIgnoreCase("2")) {
System.out.println("Well done! Puzzle solved.");
solved = true;
} else if (userInput.equalsIgnoreCase("1")
|| userInput.equalsIgnoreCase("3")) {
System.out.println("Wrong Prepare to die!");
// user.setHealthpoints(0);
solved = false;
}
} else if (userInput.equalsIgnoreCase("2")
|| userInput.equalsIgnoreCase("3")) {
System.out.println("Wrong Prepare to die!");
// user.setHealthpoints(0);
solved = false;
}
return solved;
}
/**
* Method: solvingPuzzle if the user enters the wrong answer he is being
* eaten by monster.
*
* @return boolean
**/
public static boolean solvingTripleRiddle(String userInput) {
boolean solved = false;
Scanner input = new Scanner(System.in);
if (userInput.equalsIgnoreCase("2")) {
// second riddle
System.out.println(TRIPLERIDDLE2);
userInput = input.next();
if (userInput.equalsIgnoreCase("1")) {
// third riddle
System.out.println(TRIPLERIDDLE3);
userInput = input.next();
if (userInput.equalsIgnoreCase("3")) {
System.out.println("Well done! Puzzle solved.");
solved = true;
} else if (userInput.equalsIgnoreCase("1")
|| userInput.equalsIgnoreCase("2")) {
System.out.println("Wrong Prepare to die!");
// user.setHealthpoints(0);
solved = false;
}
} else if (userInput.equalsIgnoreCase("2")
|| userInput.equalsIgnoreCase("3")) {
System.out.println("Wrong Prepare to die!");
// user.setHealthpoints(0);
solved = false;
}
} else if (userInput.equalsIgnoreCase("1")
|| userInput.equalsIgnoreCase("3")) {
System.out.println("Wrong Prepare to die!");
// user.setHealthpoints(0);
solved = false;
}
return solved;
}
}