-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.java
More file actions
67 lines (56 loc) · 2.06 KB
/
Copy pathMain.java
File metadata and controls
67 lines (56 loc) · 2.06 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
package com.collections;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Main {
public static void main(String[] args) {
Theatre theatre = new Theatre("Olympian", 8, 12);
if (theatre.reserveSeat("D12")) {
System.out.println("Please pay for D12");
} else {
System.out.println("Seat already reserved");
}
if (theatre.reserveSeat("D12")) {
System.out.println("Please pay for D12");
} else {
System.out.println("Seat already reserved");
}
if(theatre.reserveSeat("B13")) {
System.out.println("Please pay for B13");
} else {
System.out.println("Seat already reserved");
}
List<Theatre.Seat> reverseSeats = new ArrayList<>(theatre.getSeats());
Collections.reverse(reverseSeats);
printList(reverseSeats);
List<Theatre.Seat> priceSeats = new ArrayList<>(theatre.getSeats());
priceSeats.add(theatre.new Seat("B00", 13.00));
priceSeats.add(theatre.new Seat("A00", 13.00));
Collections.sort(priceSeats, Theatre.PRICE_ORDER);
printList(priceSeats);
// Collections.shuffle(seatCopy);
// System.out.println("Printing seatCopy");
// printList(seatCopy);
// System.out.println("Printing theatre.seat");
// printList(theatre.seats);
//
// Theatre.Seat minSeat = Collections.min(seatCopy);
// Theatre.Seat maxSeat = Collections.max(seatCopy);
// System.out.println("Min seat number is " + minSeat.getSeatNumber());
// System.out.println("Max seat number is " + maxSeat.getSeatNumber());
//
// sortList(seatCopy);
// System.out.println("Printing sorted seatCopy");
// printList(seatCopy);
//
// List<Theatre.Seat> newList = new ArrayList<>(theatre.seats.size());
// Collections.copy(newList, theatre.seats);
}
public static void printList(List<Theatre.Seat> list) {
for (Theatre.Seat seat : list) {
System.out.print(" " + seat.getSeatNumber() + " $" + seat.getPrice());
}
System.out.println();
System.out.println("======================================================================");
}
}