-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocation.java
More file actions
89 lines (75 loc) · 2.31 KB
/
Location.java
File metadata and controls
89 lines (75 loc) · 2.31 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
import java.util.ArrayList;
public class Location {
private String address;
private String locationName;
private int locationID;
private ArrayList<Movie> movies;
public Location(String address, String locationName, int locationID){
this.address = address;
this.locationName = locationName;
this.locationID = locationID;
movies = new ArrayList<Movie>();
}
//setters
public void setAddress(String address) {
this.address = address;
}
public void setLocationName(String locationName) {
this.locationName = locationName;
}
public void setLocationID(int locationID) {
this.locationID = locationID;
}
public void setMovies(ArrayList<Movie> movies) {
this.movies = movies;
}
//getters
public String getAddress() {
return address;
}
public String getLocationName() {
return locationName;
}
public int getLocationID() {
return locationID;
}
public ArrayList<Movie> getMovies() {
return movies;
}
//more functions
public boolean addMovie(Movie movie) {
Movie toAdd = null;
// check if the movie already exists in the list
// checking by ID to prevent duplicate Hard Copies of a movie
for (Movie current : this.movies) {
if (current.getMovieID() == movie.getMovieID()) {
toAdd = current;
break;
}
}
if (toAdd == null) {
// if the movie does not exist, add it
this.movies.add(movie);
return true; // movie was added
} else {
System.out.println("Movie with ID " + movie.getMovieID() + " already exists.");
return false;
}
}
public void removeMovie(Movie movie){
// this for now, but need to implement
if (movies.contains(movie)){
movies.remove(movie);
} else {
//print that no movie exist in list that matches given movie
}
}
public boolean hasMovie(Movie movie){
// check arraylist if it has this movie
//return int depending on true or not !
return false; // this for now, but need to implement
}
public String getName() {
return this.locationName;
}
}