-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMovie.java
More file actions
110 lines (85 loc) · 2.54 KB
/
Movie.java
File metadata and controls
110 lines (85 loc) · 2.54 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
import java.util.LinkedList;
public class Movie {
private String name;
private String time;
private LinkedList<Ticket> tickets = new LinkedList<Ticket>();
private Seats seats;
private String theatre;
private String date;
private String day;
private int id;
private int tickNumber = 0;
private boolean exclusive;
Movie(String id, String Theatre, String Movie, String dateM, String dayM, String timeM, String seats, boolean exclusive){
this.id = Integer.parseInt(id);
theatre = Theatre;
this.name = Movie;
this.date = dateM;
this.day = dayM;
this.time = timeM;
this.seats = new Seats(Integer.parseInt(seats));
this.exclusive = exclusive;
}
public String getName(){
return name;
}
public String getDate(){
return date;
}
public boolean getExclusive(){
return exclusive;
}
public String getDay(){
return day;
}
public String getTime(){
return time;
}
public String details(){
String details = "\nid: "+ id +" showing at "+theatre;
details +="\ndate: " + date;
details +="\ntime: " + time;
details +="\n";
return details;
}
public void decreaseSeats(String[] n){
addTickets(n);
seats.decrease(n);
}
public void increaseSeats(String n){
seats.increase(n);
}
public Seats getSeats(){
return seats;
}
public void addTickets(String[] n){
for(int i = 0 ; i < n.length; i++){
Ticket newT = new Ticket(n[i]);
tickets.add(newT);
}
}
public String getTicketDetails(String n){
String ticketDetails ="";
for(int i = 0 ; i < tickets.size(); i++){
if(tickets.get(i).getSeat().equals(n)){
ticketDetails += "Ticket for seat "+n;
ticketDetails += " has code: "+ tickets.get(i).getCode()+"\n";
}
}
return ticketDetails;
}
public String getTheatre(){
return theatre;
}
public String removeTickets(String code){
for(int i = 0 ; i < tickets.size(); i++){
if(tickets.get(i).getCode().equals(code)){
increaseSeats(tickets.get(i).getSeat());
String s ="Booking for "+tickets.get(i).getSeat()+" was cancelled";
tickets.remove(i);
return s;
}
}
return "Incorrect code!";
}
}