-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadvenGame.java
More file actions
97 lines (89 loc) · 3.6 KB
/
advenGame.java
File metadata and controls
97 lines (89 loc) · 3.6 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
/**
* Created by fattyduck on 3/24/15.
*/
import java.util.Scanner;
public class advenGame {
public static void main(String[] args){
Scanner scan= new Scanner(System.in);
String upstairs, downstairs, kitchen, bedroom, fridge, input;
int area=1;
downstairs="You are in a creepy house! Would you like to go \"upstairs\" or into the\n" +
"\"kitchen\"?";
//area 1
upstairs="Upstairs you see a hallway. At the end of the hallway is the master\n" +
"\"bedroom\". Or, you can go back \"downstairs\". Where would you like to go?";
//area 2
kitchen="There is a long countertop with dirty dishes everywhere. Off to one side\n" +
"there is, as you'd expect, a refrigerator. You may open the \"refrigerator\".";
//area 3
fridge="Inside the refrigerator you see food and stuff. It looks pretty nasty.\n" +
"Would you like to eat some of the food? (\"yes\" or \"no\")";
//area 4
bedroom="In the bed room you see a bed. It looks pretty nasty.\n" +
"Would you like to take a nap? (\"yes\" or \"no\")";
//area 5
System.out.println("Welcome and hit enter to play");
input=scan.nextLine();
while(area!=0){
if(area==1){
System.out.println(downstairs);
input=scan.nextLine();
if(input.equalsIgnoreCase("kitchen")){
area=3;
}else if (input.equalsIgnoreCase("upstairs")){
area=2;
}else{
System.out.println("Don't know what you talking about!");
area=1;
}
}
if(area==2){
System.out.println(upstairs);
input=scan.nextLine();
if(input.equalsIgnoreCase("bedroom")){
area=5;
}else if (input.equalsIgnoreCase("downstairs")){
area=1;
}else{
System.out.println("Don't know what you talking about!");
area=2;
}
} if(area==3){
System.out.println(kitchen);
input=scan.nextLine();
if(input.equalsIgnoreCase("refrigerator")){
area=4;
}else if (input.equalsIgnoreCase("back")){
area=1;
}else{
System.out.println("Don't know what you talking about!");
area = 3;
}
} if(area==4){
System.out.println(fridge);
input=scan.nextLine();
if(input.equalsIgnoreCase("yes")){
System.out.println("You have died of food poisoning");
break;
}else if (input.equalsIgnoreCase("no")){
area=3;
}else{
System.out.println("Don't know what you talking about!");
area=4;
}
} if(area==5){
System.out.println(bedroom);
input=scan.nextLine();
if(input.equalsIgnoreCase("yes")){
System.out.println("You woke up staring the owner and got kicked out of the house");
break;
}else if (input.equalsIgnoreCase("no")){
area=2;
}else{
System.out.println("Don't know what you talking about!");
area=5;
}
}
}
}
}