P7.5– A theater seating chart is implemented as a two-dimensional array of ticket prices, like this:…

P7.5– A theater seating chart is
implemented as a two-dimensional array of ticket prices, like
this:
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 20 20 20 20 20 20 10 10
10 10 20 20 20 20 20 20 10 10
10 10 20 20 20 20 20 20 10 10
20 20 30 30 40 40 30 30 20 20
20 30 30 40 50 50 40 30 30 20
30 40 50 50 50 50 50 50 40 30
(Note that there are 9 rows, and 10 columns).
Program Function
We will write a program that allows a user to pick a seat to
purchase.  The program will:

Display the seating chart with the prices as a 9×10
table.  Rows are numbered 1 thru 9 from the stage to the
back and, in each row, seats are numbered 1 thru 10 from the left
as seen from the stage facing the audience.
Prompt the user to enter a value indicating if they want to
pick a seat by location (“1”) or by price (“2”) or have the system
pick the best seat available (“3”).  The user may also
enter a “0” to quit the program.  If they want to pick by
location, prompt for row and seat number. If by price, prompt for
price (10,20,30,40, or 50).
When a user specifies a seat by location or price, make sure it
is available.  If not, tell the user it is not available
and give them another chance.  If all seats are sold,
tell the user and don’t give them another chance.  
If the seat is available mark it sold by changing the price to
0 in the table and tell the user:

The price if the selection was by location; or
The location if the selection was by price; or
The price and the location if the selection was best
available.

After each seat is sold, re-display the current seating chart
(showing the available seats).
End the program when all seats are sold or when the user
enters  “0” to quit, whichever comes first.

Program Design
You will have two classes in this program:

The TheaterSeatTesterclass that accepts seat
requests from the user and services those requests with the
appropriate method calls.  It runs until all seats are
sold or the user quits.
The TheaterSeatSellerclass that displays the
seating chart on request, looks for available seats on request, and
marks requested seats sold.

TheaterSeatTester Class

Declare and initialize a test array with the seat price values
shown in the table above and pass that array to a newly created
TheaterSeatSeller object as a constructor
parameter.  (Seat prices may vary depending on what
who/what the entertainment is and what day/time the shows
are).
Declare and initialize a totalSold counter to count the seats
sold.  The definition of no more seats available will be
when totalSold equals the total number of seats in the
theater.
Declare and initialize any additional variables necessary to
perform the functions below.
Run (loop) to repeatedly find and mark sold seats in the
theater until all are sold or the user enters “0” to quit.
Display the current seating chart by calling
theprintSeats method.
Prompt the user for input as described in the program function
above.  
Edit the input received for validity and repeat the prompt
until a valid response is received.
If the input is “0” display a message (e.g. “Goodbye”) and quit
the program.
If the input is “1” invoke the getByLoc
method, passing the row and seat requested.
If the input is “2” invoke the getByPrice
method passing the price requested.
If the input is “3” invoke the getBest
method.
For every seat successfully sold (a good return from any of the
get methods), increment the totalSold counter and use it to stop
the program when all seats are sold.

TheaterSeatSeller Class

Declare a 2D array named seats to be a matrix
representing the rows and seats in the theater. This is the
instance variable for the class.  The array will be
initialized in the class Constructor by copying the test array
passed in the constructor parameter to seats. This
will be a true copy, not a copy by reference.
Code a constructor for the class that will accept an array
reference of test values for the seat prices and use it to
initialize seats.  
Code a printSeatsmethod to display the
formatted seating chart on request.
Code a getByLocmethod.  It accepts
two integer parameters for row and seat and returns a Boolean
response indicating success or failure (seat was available or not).
Use the row and seat to locate the corresponding price element in
the array and determine availability (not available if
0).  If available, display a message that the seat at
that location (name the location) will be reserved and the
price.  Mark the seat sold by changing price to 0.
Code a getByPricemethod.  It accepts
a price (an integer, as prices will always be expressed as whole
dollars), and returns a Boolean response indicating success or
failure (seat was available or not).  Use price to locate
the first available seat in a row at that price closest to the
front (stage).  If available, display a message that the
seat at that price (name the price) will be reserved and the
location (row and seat number).  Mark the seat sold by
changing the price to 0.