-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocation.java
More file actions
113 lines (88 loc) · 2.79 KB
/
Location.java
File metadata and controls
113 lines (88 loc) · 2.79 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;
import CustomExceptions.*;
import Entities.*;
/**
* COMP90041, Sem1, 2023: Final Project
* @author Jule Valendo Halim
* student id: 1425567
* student email: julevalendoh@student.unimelb.edu.au
*
* Class containing instance variables connected to locations
* Class of locations to select
*/
public class Location {
//Instance Variables
private boolean trespassing;
private String latitude;
private String longitude;
private ArrayList < Entity > entities;
private String trespassingString;
//Constructors
/**
* Default constructor for Locations
*/
public Location(){
}
/**
* Constructor for location initializing instance variables with given parameters
* @param trespassing Indicates whether entities in this location are trespassing, changed to a String and stored
* @param latitude The latitude of the location
* @param longitude The logitude of the location
*/
public Location(boolean trespassing, String latitude, String longitude) {
this.entities = new ArrayList < Entity > ();
this.trespassing = trespassing;
this.latitude = latitude;
this.longitude = longitude;
if (trespassing) { //sets trespassing string depending on boolean value
this.trespassingString = "yes";
} else {
this.trespassingString = "no";
}
}
//Public Methods
//Accessors
/**
* Gets the ArrayList of entities
* @return Returns an ArrayList of entities, containg all the entities in a location
*/
public ArrayList < Entity > getEntityArray() {
return entities;
}
/**
* Gets the trespassing status of entities in the location
* @return Returns a boolean indicating if entities are trespassing
*/
public boolean returnTrespassing() {
return this.trespassing;
}
/**
* Gets the latitude of a location
* @return Returns a String of the latitude of current location
*/
public String getLocationLatitude() {
return this.latitude;
}
/**
* Gets the longitude of a location
* @return Returns a String of the longitude of current location
*/
public String getLocationLongitude() {
return this.longitude;
}
/**
* Gets the trespassing status of a location as a String, either "legal" or "trespassing" will be returned
* @return Returns a String of the trespassing status of the location
*/
public String getTrespassingString() {
return trespassingString;
}
//Mutators
/**
* Adds an Entity to the location
* @param entity Entity to be added
*/
public void addEntity(Entity entity) {
entities.add(entity);
}
}