Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java I need to create a class named airplane class, below are the specifications: Airplane Class: An instance of the Airplane class should store

In Java I need to create a class named airplane class, below are the specifications: Airplane Class: An instance of the Airplane class should store a reference to an array which stores references to seats on the plane and the number of seats in first class. The Airplane class should provide the following behaviors:

A parameterized constructor that creates the array based upon the number of seats passed to it and populate the array with seats. All planes have a maximum of 40% of their seats designated as first class and the remaining 60% as coach class. For example, in a plane with 10 seats, there are 4 first class seats (at the front of the plane) and 6 coach class seats (after the end of the first class). If there isnt an even split, the plane will have slightly less than 40% first class and slightly more than 60% coach class. For example, in a plane with 14 seats, 40% would be 5.6 seats. In order to avoid going over the 40% maximum, this plane would have 5 first class seats and 9 coach class seats.

A method to determine and return the current capacity (ie. the percent of occupied seats) of a class of seat (first or coach). A method to assign a first class or coach class seat. As long as the class of seat requested is less than 50% capacity, the reservation can be completed. Since the airline wants to keeps its passengers as socially distant as possible you will have to come up with a strategy to assign seats in such a way that passengers are spaced out within their class of service. Each row in the plane only has 1 seat.

A method to cancel a specific previously reserved first class or coach class seat.

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 boolean cancelReserv() { if(status.equals("Occupied")) return true; else return false; } public String toString() { String str = new String(); str+= "The seat " + num + ", from class " +type + ", is " + status; return str; }

**can you please help with those methods? Specially the assign seat and cancel seat. I cannot have a set method in the seat class, so I am not sure how to chance the seat status from empty to occupied. Also was it a good choice to use a boolean for those methods in the seat class?

Thank you

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_2

Step: 3

blur-text-image_3

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

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

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

Answered: 1 week ago