Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java, Below is my code. When I try to run the program the seats status never changes from empty to booked, consequently I cannot

In Java,

Below is my code. When I try to run the program the seats status never changes from empty to booked, consequently I cannot see which seats are available. Not sure how to fix this problem. Thank you

***Also the plane should be divide in 50% first and 50% Economic class, not sure how to do that either. If you can put comments explaining the changes that need to be done will be great.

public class Seat { private String type; private String status; private int num; public Seat(String t, int n) { type = t; if(type.equals("First")) t = "First"; else t = "economic"; status = new String("Empty"); num = n; } public String getType() { return type; } public int getNum() { return num; }

public String getStatus() { return status; } public boolean seatReserv() { if(status.equals("Empty")) return true; else return false; } public String toString() { String str = new String(); str+= "The seat " + num + ", from class " +type + ", is " + status; return str; }

}

public class Airplane { private Seat[] planeSeats; private int firstClass;

public Airplane(int seats) { seats = new Seat[seats];

for(int i = 0; i < planeSeats.length; i++) {

seats[i]= new Seat("First, Economic", i+1); }

}

public String seatAssignmet(String seatType) { for(int i = 0; i < planeSeats.length; i++) if(seats[i].seatReserv() == true) seatType = "First"; else seatType = "Economic"; return seatType; } public boolean cancelReserv(int num) { if(seats[num].geStatus().equals("Booked")) { seats[num].getStatus().equals("Empty"); return true; } return false; } public String toString() { String str = new String(); for (int i = 0; i < planeSeats.length; i++) str = str + seats[i].toString() + " "; return str; }

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago