-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLocation.java
More file actions
113 lines (81 loc) · 2.7 KB
/
Location.java
File metadata and controls
113 lines (81 loc) · 2.7 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
import java.util.ArrayList;
public class Location extends Main {
//Instance variables for the properties of the location
private String name;
private String description;
private boolean hasEvent;
private Location[] exits;
//Initializing location with name, description, and event status
public Location() {
this.name = name;
this.description = description;
this.hasEvent =hasEvent;
exits = new Location[2]; //there should be 2 exits within a location
ArrayList<String> Locations = new ArrayList<String>();
Locations.add("Menu");//0
Locations.add("Plane Crash");//1
Locations.add("River");//2
Locations.add("Beach");//3
Locations.add("Jungle");//4
Locations.add("Cave");//5
Locations.add("Village");//6
}
//Getter methods for retrieving location information
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public boolean hasEvent() {
return hasEvent;
}
//Setter method to exit location at a specific index
public void setExit(int index, Location exitLocation) {
exits[index] = exitLocation;
}
//Getter method to exit location at a specific index
public Location getExit(int index) {
return exits[index];
}
//Method to simulate entering a location
public void enterLocation() {
System.out.println("You have entered the " + name + ".");
System.out.println(description);
//Checks of location has an event
if (hasEvent) {
handleEvent();
}
}
//Method to handle specific events based on the location
private void handleEvent() {
// Implement event logic for the location
System.out.println(" LOOK, something appears to be happening at the " + name + ".");
// HARDCODE BEFORE player enters location
//Switch statements to handle events based on the location's name
switch (name) {
//plane crash location
case "Plane Crash Site":
break;
//Jungle Location
case "Jungle":
break;
//Cave SubLocation
case "Cave":
break;
//Village Location
case "Village":
break;
//River Location
case "River":
break;
//Beach Location
case "Beach":
default:
break;
}
}
public void location() {
// TODO Auto-generated method stub
}
}