Posted: October 27th, 2022

Data structures & algorithms

 Write a program named MultiD-AList that satisfies the attached requirements. 

CPSC-4355

Don't use plagiarized sources. Get Your Custom Essay on
Data structures & algorithms
Just from $13/Page
Order Essay

ArrayList Assignment

Demonstrate defining, loading, printing and storing a Multidimensional ArrayList.

Just as the elements of an array can be defined to be arrays themselves (thus making

multidimensional arrays), so can an ArrayList be defined to contain elements that are

themselves an ArrayList (thus making multidimensional ArrayLists).

1. Define a multidimensional ArrayList named seats to hold the status (available,

taken) of seats in a theatre.

a. There are three dimensions

i. The seating levels (main floor, 1st balcony, 2nd balcony).

ii. The rows on a given level.

iii. The seats in a given row.

iv. Define seats as an ArrayList of levels where each level is an ArrayList

of rows and each row is an ArrayList of seats (thus the 3 dimensions).

b. Since the status can only be two values, the data type is Boolean.

2. Initialize the ArrayList so that all seats are taken except the first seat of each row.

a. True = seat is taken; false = seat is available

3. Display the ArrayList by seating level on screen.

4. Store the ArrayList by seating level to a file using PrintStream (recall from section

6.4 in book).

CPSC-4355
ArrayList Assignment

NOTE that the new command syntax allows the right side to get the data type from the left side of the

statement without repeating it:

ArrayList variableName = new ArrayList<>();

NOTE that since the ArrayList does not have predetermined sizes, the dimensions for the seating layout

must be stored someplace. Use the following 2-dimensional array to hold the rows and seats for each

seating level of the theatre.

int [][] seatsLayout = {{4,5}, // rows and seats on the main floor

{3,4}, // rows and seats on the 1st balcony

{1,3}}; // rows and seats on the 2nd balcony

Output to the screen and file should look as follows:

[[false, true, true, true, true], [false, true, true, true, true], [false, true, true, true, true], [false, true,

true, true, true]]

[[false, true, true, true], [false, true, true, true], [false, true, true, true]]

[[false, true, true]]

Expert paper writers are just a few clicks away

Place an order in 3 easy steps. Takes less than 5 mins.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00

Order your essay today and save 30% with the discount code ESSAYHELP