Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
The purpose of this assignment is to reinforce your understanding of linear data
structures such as lists and queues. For this problem you will be provided with sample
tests in Mimir. All input is done via the console and all output is to be done to
the console as well. You must submit your assignment via Mimir, and you can test
it by submitting your code. Note: for this assignment you are expected to install
and use an IDE (other than Mimir) to develop your code. The problem in this assignment
is described in three stages. Each stage builds on the next. Each stage
subsumes the previous stage. I.e., if completing Stage III, means completing Stage II and Stage I.
The Halifax International Airport is redesigning their Airport Security Screening facilities and are trying to
determine how many security check stations are needed. To determine this, they have hired you to write
a simulation to determine how long it takes passengers to get through a security check. In real life, the
total time depends on many factors, such as the number of stations there are, the number of bags a
passenger has, the number of passengers arriving at security, and whether some passengers pack prohibited
items, requiring a manual search of their bags. To keep things simple, you have decided to start with
a simple simulation and increase its complexity from one stage to the next. You have noted that the
factors that contribute most to the wait time are: waiting to enter the station and waiting to collect the
bags after they have gone through the scanner, with the occasional manual inspection to slow things
down. Naturally, a passenger cannot collect their bags until the passenger ahead of them has done so.
Write a program called AirportSecuritySim.java that simulates an Airport Security Checkpoint.
Each simulation consists of several rounds. In each round zero or more passengers arrive at the airport
security checkpoint, each carrying zero or more bags. They are assigned to a screening station with the
shortest line. They then wait zero or more rounds for their turn to place their bags on the conveyor belt,
walk through the scanner, and collect their bags on the other side before leaving to catch their flight. Your
program will simulate this process, outputting when the passengers arrive and when they leave.
Stage I: Airport Security Simplified
In this stage, all passengers will be travelling light, i.e., they will have no bags and there is only one screening
station that is operational.
Input
The input is divided into two parts: (i) a list screening stations that are open at the security check point
and (ii) a list of passengers arriving in each round. The first part of the input isthe list of screening stations.
The first part is a single line that contains an integer denoting the number of stations (S), followed by S
integers encoding the stations numbers that are open. For example, this input
3 2 4 8
means there are 3 open screening stations: 2, 4, and 8. In Stage 1, only one station will be open.
The second part of the input is the list of the passengers and their bags arriving in each round. The first
line contains a single integer (R) denoting the number of rounds in which passengers may be arriving. This
is followed by R sections, one section per round. Each section begins with a line containing a single integer
(P) denoting the number of passengers arriving at the security check point in this round. This is followed
by P lines encoding each passenger and their bags. In Stage 1, each passenger is encoded by a single
word, denoting the passenger’s name followed by a 0, indicating the passenger has 0 bags. E.g., the input
5
2
Alice 0
Bob 0
0
1
Carol 0
3
Dave 0
Eve 0
Fred 0
1
Ginny 0
means there are 5 rounds: In round 1, Alice and Bob arrive, each carrying 0 bags; in round 2, no passengers
arrive; in round 3, Carol arrives, with no bags; in round 4 Dave, Eve, and Fred arrive; and in round 5, Ginny
arrive, also with no bags. In Stage 1 all passengers carry 0 bags, which makes the screening a little faster.
Processing
Your program should simulate the operations of the security checkpoint. The main loop performs one
round per iteration. The pseudocode for your main program is:
1. Read in the screening stations and the number of rounds
2. Loop for the specified number of rounds:
a. Read in the passengers arriving in this round. For each passenger
i. Read in the bags that they are carrying (in Stage 1 no one has bags)
ii. Assign each passenger to a screening station.
iii. Generate the required output for the passenger (see Output Section).
b. For each screening station
i. The passenger at the head of the line proceeds through the screening and leaves
ii. Generate the required output for the passenger (see Output Section)
3. Loop until all the passengers have left the security checkpoint
a. For each screening station
i. The passenger at the head of the line proceeds through the screening and leaves
ii. Generate the required output for the passenger (see Output Section)
Output
When a passenger enters a screening station line, the program should output:
Name(B) enters station N in round T
where
? Name is the passenger’s name
? B is the number of bags the passenger has
? N is the station they have been assigned to
? T is the current round. Rounds are numbered 1, 2, 3, … R
When a passenger leaves a screening station line, the program should output:
Name(B) leaves station N in round T
The output should be to the console, and each line terminated by a newline. If two passengers are arriving
or leaving at the same time, the output should be the same as the input order.
Alice(0) enters station 7 in round 1
Bob(0) enters station 7 in round 1
Alice(0) leaves station 7 in round 1
Bob(0) leaves station 7 in round 2
Carol(0) enters station 7 in round 3
Carol(0) leaves station 7 in round 3
Dave(0) enters station 7 in round 4
Eve(0) enters station 7 in round 4
Fred(0) enters station 7 in round 4
Dave(0) leaves station 7 in round 4
Ginny(0) enters station 7 in round 5
Eve(0) leaves station 7 in round 5
Fred(0) leaves station 7 in round 6
Ginny(0) leaves station 7 in round 7
Hints and Suggestions
You can implement this assignment as you wish, however, the following design is recommended:
? Passenger class
o – name : String passenger’s name
o + Passenger(String) sets the name of the passenger
o + getName() : String returns the name of the passenger
o + toString() : String returns a String of the form “Name(numberOfBags)”