Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Airline Reservation You must use Object Oriented Programming to design this proj

ID: 3635194 • Letter: A

Question

Airline Reservation You must use Object Oriented Programming to design this project. Write a reservation system for an airline flight. Assume the airplane has 10 rows with 4 seats in each row. Use a two dimensional array of strings to maintain a seating chart. In addition create a array to be used as a waiting list in case the plane is full. The waiting list should be "first come first serve" that is people who are added early in the list get the priority over those who are added later. Allow the user to add three options 1. Add a passenger to the list. a. Request the passenger's name. b. Display a chart of the seats in the airplane in a tabular form c. If seats are available let the passenger choose a seat. Add the passenger to the seating chart. d. If no seats are available, place the passenger on the waiting list. 2. Remove a passenger from the list a. Request the passengers name b. Search the seating chart for the passenger's name and delete it. c. If the waiting list is empty, update the array so that the seat is available, d. If the waiting list is not empty remove the first person from the list, and give him or her the newly vacated seat. 3. Quit You will need to use string methods defined in java.lang.String in the documentation reference. String comparision function names are as follows equal, equalIgnoreCase. You must use OOP Concepts learnt in the class. (As much as possible.) ////////////////////////////////////////////////////////////////////////// Flight
        SeatingChart sc;
        WaitingList wl;
        AddPassenger()
        RemovePassenger()       
       
    SeatingChart
        Passenger [] pass = new Passenger[40];
        printSeatingChart()
        getSeatChoicefromUser() //prompts the user to enter which seat they want to occupy.   
        setPassenger()
        getPassenger() //given the location in Seating Chart.
        search()
        removePassenger()
            //delete passenger from seating chart
        reconcileWithWaitingList()
            //If the waiting list is not empty remove the first person from the list, and give him or her the newly vacated seat.
        addPassengerToWaitingList()


    WaitingList
        Passenger [] waitlist = new WaitingList[10];
        printWaitingList()
        setPassenger() //FIFO
        getPassenger()
       
    Passenger
        Instance Variables
        FirstName
        LastName
        getName()
        setFirstName()
        setLastName() Airline Reservation You must use Object Oriented Programming to design this project. Write a reservation system for an airline flight. Assume the airplane has 10 rows with 4 seats in each row. Use a two dimensional array of strings to maintain a seating chart. In addition create a array to be used as a waiting list in case the plane is full. The waiting list should be "first come first serve" that is people who are added early in the list get the priority over those who are added later. Allow the user to add three options 1. Add a passenger to the list. a. Request the passenger's name. b. Display a chart of the seats in the airplane in a tabular form c. If seats are available let the passenger choose a seat. Add the passenger to the seating chart. d. If no seats are available, place the passenger on the waiting list. 2. Remove a passenger from the list a. Request the passengers name b. Search the seating chart for the passenger's name and delete it. c. If the waiting list is empty, update the array so that the seat is available, d. If the waiting list is not empty remove the first person from the list, and give him or her the newly vacated seat. 3. Quit You will need to use string methods defined in java.lang.String in the documentation reference. String comparision function names are as follows equal, equalIgnoreCase. You must use OOP Concepts learnt in the class. (As much as possible.) ////////////////////////////////////////////////////////////////////////// Flight
        SeatingChart sc;
        WaitingList wl;
        AddPassenger()
        RemovePassenger()       
       
    SeatingChart
        Passenger [] pass = new Passenger[40];
        printSeatingChart()
        getSeatChoicefromUser() //prompts the user to enter which seat they want to occupy.   
        setPassenger()
        getPassenger() //given the location in Seating Chart.
        search()
        removePassenger()
            //delete passenger from seating chart
        reconcileWithWaitingList()
            //If the waiting list is not empty remove the first person from the list, and give him or her the newly vacated seat.
        addPassengerToWaitingList()


    WaitingList
        Passenger [] waitlist = new WaitingList[10];
        printWaitingList()
        setPassenger() //FIFO
        getPassenger()
       
    Passenger
        Instance Variables
        FirstName
        LastName
        getName()
        setFirstName()
        setLastName()

Explanation / Answer

Hope this will helps,
please rate!


//First class Airline class

import java.util.Scanner;


public class Airline {

Passenger[]passengers = new Passenger[40];
Passenger[] waitList = new Passenger[10];
Scanner sc = new Scanner(System.in);

public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Welcome to Airline Reservations");
System.out.println("Choose from the list what you would like to do");
System.out.println("1: Add a passenger to the list");
System.out.println("2: Remove a passenger from the list");
System.out.println("3: Quit");
Airline flight5 = new Airline();
int choice = scan.nextInt();
while(choice<3 && choice>0){
if(choice == 1){
System.out.print("Enter First Name: ");
String first = scan.next();
System.out.print("Enter Last Name: ");
String last = scan.next();
System.out.println("Choose an open seat: ");
System.out.println("O = Open X = taken");
System.out.println("Numbered from left to right");
flight5.printSeatingChart();
System.out.print("Seat chosen: ");
int seat = scan.nextInt();
while(seat>40 || seat < 0){
System.out.print("Enter a valid seat");
seat = scan.nextInt();
}
Passenger p = new Passenger(first, last, seat);
flight5.addPassenger(p);
System.out.println("Done adding passenger to list");
}
if(choice == 2){
System.out.print("Enter First Name: ");
String first = scan.next();
System.out.print("Enter Last Name: ");
String last = scan.next();
flight5.removePassenger(first+" "+last);
System.out.println("Successfully removed passenger from list");
}
System.out.println("");
System.out.println("Choose from the list what you would like to do");
System.out.println("1: Add a passenger to the list");
System.out.println("2: Remove a passenger from the list");
System.out.println("3: Quit");
choice = scan.nextInt();
}
}

public void addPassenger(Passenger p){
int index = p.getSeat();
if(passengers[index-1] == null){
passengers[index-1] = p;
}
else{
addPassengerToWaitingList(p);
}
}

public void addPassengerToWaitingList(Passenger p) {
for(int i =0; i<10; i++){
if(waitList[i]==null){
waitList[i]=p;
}
}

}

public void reconcileWaitList(){
for(int i =0; i<10; i++){
if(i<9) waitList[i] = waitList[i+1];
else waitList[i] = null;
}
}

public void removePassenger(String f){
for(int i = 0; i< 40; i++){
if(passengers[i]!= null){
if(f.equalsIgnoreCase(passengers[i].getName())){
if(waitList[0] == null){
passengers[i] = null;
}
else{
passengers[i] = waitList[0];
reconcileWaitList();
}
}
}
}
}

public void printSeatingChart(){
for(int i = 0; i<40; i+=4){
for(int j =0; j<4; j++){
if(passengers[i+j]==null){
System.out.print("O ");
}
else System.out.print("X ");
}
System.out.println("");
}
}

public int getSeatChoice(){
System.out.println("Choose a seat you would like to sit in");
int choice = sc.nextInt();
return choice;
}


}



//Second class to handle the actual Passenger


public class Passenger {
public String firstName;
public String lastName;
public int seatNumber;

public Passenger(){
firstName = "First";
lastName = "last";
seatNumber = -1;
}

public Passenger(String f, String l, int seat){
firstName = f;
lastName = l;
seatNumber = seat;
}

public String getName(){
return firstName + " "+ lastName;
}

public void setFirst(String f){
firstName = f;
}

public void setLast(String l){
lastName = l;
}

public int getSeat(){
return seatNumber;
}

public void setSeat(int n){
seatNumber = n;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote