Menu
support@nursinghomework.org
+1 714-215-3097

(Solved) : Write Class Used Assign Seats Commercial Airplane Airplane 13 Rows 6 Seats Row Row 1 2 Fir Q35537365

Write a class that can be used to assign seats for a commercialairplane. The airplane has

13 rows, with 6 seats in each row. Row 1 and 2 are first class;the remaining rows are

economy class. Also, rows 1 through 7 are nonsmoking. Yourprogram must prompt the

user to enter the following information:

a. Ticket type (first class or economy class)

b. For economy class, the smoking or nonsmoking section

c. Desired seat (example: 7F)

Output the seating assignment in the following form:

A

B

C

D

E

F

Row 1 * * X * X X

Row 2 * X * X * X

Row 3 * * X X * X

Row 4 X * X * X X

Row 5 * X * X * *

Row 6 * X * * * X

Row 7 X * * * X X

Row 8 * X * X X *

Row 9 X * X X * X

Row 10 * X * X X X

Row 11 * * X * X *

Row 12 * * X X * X

Row 13 * * * * X *

Here, * indicates that the seat is available; X indicates thatthe seat is occupied. Make this

a menu-driven program; show the user’s choices and allow theuser to make the

appropriate choices.

1. Import the template provided below:

/**

* This is airplane seats assigning program.

*

* @author (Chris Lululala)

* @version

* @since

*

*/

import java.util.*;

public class ASA

{

//attributes

//constructors

/**

* Constructor for objects of class ASA

* declare and initialize the local variables.

* Initialize the seats array with ‘*’ character.

* Until a user choose to stop the program, repeat theprogram.

* First display the current seat assignment map.

* Display the menus and instructions, then a user choose one

* from the menu then type in required seat number. Nextassign

* the user to the user’s requested seat. Then report theresult.

*/

public ASA()

{

// declare and initialize the local variables

Scanner scnr = new Scanner(System.in);

int choice; //from the menu

char[][] seats = new char[13][6];

String seatNo = “”; //user input of the seat#

int row = 0; //user requested seat row index number for theseats array

int column = 0; //user requested seat column index number forthe seats array

// initialize the seats array with ‘*’ character.

// real seat assignment operation here.

}

//methods

/**

* printSeats method gets an array for seats

* then prints the current status of seats.

*

* @param seatStatus a parameter for the current seats array.

* @return no returns at all.

*/

public void printSeats(char [][] seatStatus)

{

}

/**

* printMenu method prints the menu of this program’soperations.

*

* @param no parameter.

* @return no returns at all.

*/

public void printMenu()

{

}

/**

* First method gets an array for seats, and a seat number,

* then assign the requested seat. If already assigned by anotheruser

* or requested wrong seats, prints a warning message.

*

* @param seatStatus a parameter for the current seats array.

* @param row row index number of seatStatus for the requestedseat

* @param col column index number of seatStatus for the requestedseat

* @return no returns at all.

*/

public void First(char [][] seatStatus, int row, int col)

{

}

/**

* EconomySmoking method gets an array for seats, and a seatnumber,

* then assign the requested seat. If already assigned by anotheruser

* or requested wrong seats, prints a warning message.

*

* @param seatStatus a parameter for an seats array.

* @param row row number of the requested seat

* @param col column number of the requested seat

* @return no returns at all.

*/

public void EconomySmoking(char [][] seatStatus, int row, intcol)

{

}

/**

* EconomyNonSmoking method gets an array for seats, and a seatnumber,

* then assign the requested seat. If already assigned by anotheruser

* or requested wrong seats, prints a warning message.

*

* @param seatStatus a parameter for an seats array.

* @param row row number of the requested seat

* @param col column number of the requested seat

* @return no returns at all.

*/

public void EconomyNonSmoking(char [][] seatStatus, int row, intcol)

{

}

}

2. There’s no attribute required this time.

3. Define the constructor.

a. ASA: Constructor for objects of class ASA declare andinitialize the local

variables. Initialize the seats array with ‘*’ character. Untila user choose

to stop the program, repeat the program. First display thecurrent seat

assignment map. Display the menus and instructions, then a userchoose

one from the menu then type in required seat number. Next assignthe

user to the user’s requested seat. Then report the result.

4. Define the methods as following:

a. printSeats method: This method gets one parameter ofcharacter array to

get the current seat assign status. Doesn’t return at all. Mustgenerate the

output like below:

A B C D E F

Row 1 * * * * * *

Row 2 * * * * * *

Row 3 * * * * * *

Row 4 * * * * * *

Row 5 * * * * * *

Row 6 * * * * * *

Row 7 * * * * * *

Row 8 * * * * * *

Row 9 * * * * * *

Row 10 * * * * * *

Row 11 * * * * * *

Row 12 * * * * * *

Row 13 * * * * * *

b. printMenu method: This method doesn’t have any parameter andreturn.

Just print the menu of operations for airplane seat assignments.Must

generate the print-out like following:

MENU=======================================

1. First Class

2. Economy Class – Smoking

3. Economy Class – Non Smoking

4. Quit this program

===========================================

Enter your choice (1,2,3, or 4):

c. First: This method assigns the first class seats. It needs 3parameters. The

character array parameter “seatStatus” is to get the currentseat assignment

status. Row and col parameters are to get row and column numbersof the

requested seat. Successfully assigned or not, the result reportmust be

displayed to the monitor. The examples of the result report areas

following:

MENU=======================================

1. First Class

2. Economy Class – Smoking

3. Economy Class – Non Smoking

4. Quit this program

===========================================

Enter your choice (1,2,3, or 4):

1

Enter the seat number you want:

1a

Your requested seat(1A) is reserved for you.

A B C D E F

Row 1 X * * * * *

Row 2 * * * * * *

Row 3 * * * * * *

Row 4 * * * * * *

Row 5 * * * * * *

Row 6 * * * * * *

Row 7 * * * * * *

Row 8 * * * * * *

Row 9 * * * * * *

Row 10 * * * * * *

Row 11 * * * * * *

Row 12 * * * * * *

Row 13 * * * * * *

MENU=======================================

1. First Class

2. Economy Class – Smoking

3. Economy Class – Non Smoking

4. Quit this program

===========================================

Enter your choice (1,2,3, or 4):

1

Enter the seat number you want:

1a

Your requested seat has already assigned to another

customer.

MENU=======================================

1. First Class

2. Economy Class – Smoking

3. Economy Class – Non Smoking

4. Quit this program

===========================================

Enter your choice (1,2,3, or 4):

1

Enter the seat number you want:

4a

Your requested seat is not a first-class seat, try again.

This method dosen’t return.

d. EconomySmoking: This method assigns the smoking economy classseats.

It needs 3 parameters. The character array parameter“seatStatus” is to get

the current seat assignment status. Row and col parameters areto get row

and column numbers of the requested seat. Successfully assignedor not,

the result report must be displayed to the monitor. This methoddosen’t

return.

e. EconomyNonSmoking: This method assigns the non-smokingeconomy

class seats. It needs 3 parameters. The character arrayparameter

“seatStatus” is to get the current seat assignment status. Rowand col

parameters are to get row and column n

Leave a Reply

Your email address will not be published. Required fields are marked *