JAVA
java
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
import java.util.Random;
class Theatre {
Random rand = new Random();
private int theatreCapacity = 200; //Theatre Hall Size
private boolean[] theatreHall; // Theatre Hall
private boolean selecting = true; //Customer is selecting
private int checkingOutTime;
private int fromTheatre;
//Initialising the all theatre seats to empty.
public void setTheatre() {
theatreHall = new boolean[theatreCapacity];
for (int i = 0; i < theatreHall.length; i++) {
theatreHall[i] = false;
}
System.out.println("ALl seats in the theatre is available");
}
//Getting the theatre seats with all false (available)
public boolean[] getTheatre() {
return theatreHall;
}
//Reservation
public synchronized boolean randomReservation() {
int desiredSeats = rand.nextInt(3) + 1;
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run