-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransporter.java
More file actions
73 lines (54 loc) · 1.94 KB
/
Transporter.java
File metadata and controls
73 lines (54 loc) · 1.94 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
import java.util.ArrayList;
import java.util.HashMap;
/**
* A Transporter object which stores the location (town) of a given transporter,
* their exact coordinates (to find them easier ingame), a list of transporters
* they can send you to and how much it costs to be sent there.
*/
public class Transporter {
// these values dictate the attribute names in the JSON source file
public static final String TAG_LOCATION = "location";
public static final String TAG_COORDS = "coordinates";
public static final String TAG_GOINGTO = "transports-to";
public static final String TAG_PLACE = "to-location";
public static final String TAG_PRICE = "price";
private String location;
private String coords;
private ArrayList<HashMap<String, String>> transports_to;
/**
* Returns a new Transporter object.
*
* @param location the name of the town the transporter is in
* @param coords their exact coordinates in a string of the shape (x;y)
* @param transports_to a list of other transporters they can send you to
*/
public Transporter(String location, String coords, ArrayList<HashMap<String, String>> transports_to) {
this.location = location;
this.coords = coords;
this.transports_to = transports_to;
}
/**
* Returns the location of the transporter
*/
public String getLocation() {
return location;
}
/**
* Returns a list of places this transporter goes to
*/
public ArrayList<HashMap<String, String>> goesTo() {
return transports_to;
}
/**
* Returns a String with only the location and coordinates of the Transporter
*/
public String toStringShort() {
return location + " " + coords ;
}
/**
* Returns a String representing the Transporter object
*/
public String toString() {
return location + "\n" + coords + "\n" + transports_to;
}
}