Requirements Statement You are required to complete a Java program that implemen
ID: 667120 • Letter: R
Question
Requirements Statement
You are required to complete a Java program that implements a basic Airline Booking System (ABS). The ABS allows a client (a user or another software system) to create airports, airlines, and flights for the airlines. Each airline is associated with a set of flights. A flight has an originating airport (origin) and a destination airport (destination). The originating and destination airports cannot be the same. Each flight is associated with a flight section (e.g., first class and business class sections). Each flight section consists of seats organized in rows and columns. The system consists of a SystemManager that provides a single point of access to the functions provided (i.e., SystemManager is a facade for the program – for more information on facades search for the facade design pattern on the web).
In this assignment, you will be required to implement the following functionality:
1. Create an airport. An airport must have a name consisting of exactly three alphabetic characters. No two airports can have the same name.
2. Create an airline. An airline has a name that must have a length less than 6. No two airlines can have the same name.
3. Create a flight given an airline name, the name of an originating airport, the name of a destination airport, a flight number, and a departure date: A flight has an identifier that is a string of alphanumeric characters.
4. Create a section for a flight. The number of seat rows and columns must be provided when creating a section.
5. Find available flights. Finds all flights from an originating airport to a destination airport with seats that are not booked on a given date.
Book a seat. Books an available seat from a given originating airport to a destination airport on a particular date, on a given flight.
Print system details. Displays attribute values for all objects (e.g., airports, airplanes) in system.
Required Classes (Design Constraints)
You program must include the following classes.
SystemManager
This class provides the interface (facade) to the system. That is, clients interact with the system by calling operations in the SystemManager. The SystemManager is linked to all the airport and airline objects in the system. When it is created, the SystemManager has no airport or airline objects linked to it. To create airports and airlines, the createAirport() and createAirline() operations defined in this class must be invoked. The class also contains operations for creating sections of flights (e.g., first class and business class sections), finding available flights between two airports, and booking a seat on a flight. A printout of information on all the airports, airlines, flights, flight sections and seats is obtained by invoking displaySystemDetails()
createAirport(String n): Creates an airport object and links it to the SystemManager. The airport will have a name (code) n; n must have exactly three characters. No two airports can have the same name.
createAirline(String n) : Creates an airline object with name n and links it to the SystemManager. An airline has a name that must have a length less than 6. No two airlines can have the same name.
createFlight(String aname, String orig, String dest, int year, int month, int day, String id): Creates a flight for an airline named aname, from an originating airport (orig) to a destination airport (dest) on a particular date. The flight has an identifier (id).
createSection(String air, String flID, int rows, int cols, SeatClass s): Creates a section, of class s, for a flight with identifier flID, associated with an airline, air. The section will contain the input number of rows and columns.
findAvailableFlights(String orig, String dest): Finds all flights from airport orig to airport dest with seats that are not booked.
bookSeat(String air, String fl, SeatClass s, int row, char col): Books seat in given row and column in section s, on flight fl of airline air.
displaySystemDetails(): Displays attribute values for all objects (e.g., airports, airplanes) in system. Airport
Objects of this class represent airports. The only information maintained is the name, which must be exactly 3 characters in length.
Airline
This class maintains information about airlines. An airline can have 0 or more flights associated with it. When created an airline is not associated with any flights. All flights for a given airline must have unique flight ids.
Flight
This class maintains information about flights. A flight can be associated with 0 or more flight sections. There can only be one flight section of a particular seat class in a flight, e.g., only one business class and only one first class. The seat classes are defined by the enumerator type SeatClass which defines the values first, business and economy (see bottom of Figure 1). The major operations of Flight are summarized below.
FlightSection
This class maintains information about flight sections. A flight section has a seat class (first, business or economy) and must have at least 1 seat. hasAvailableSeats() returns true iff the section has some seats that are not booked, and bookSeat() books an available seat. A flight section can contain at most 100 rows of seats and at most 10 columns of seats.
Seat
This class maintains information about seats. Specifically, a seat has an identifier (a seat is identified by a row number and a column character, where the character is a letter from A to J), and a status which indicates whether the seat is booked or not.
Explanation / Answer
//Airline Booking System(ABS)
interface SystemManager //defining interface
{
void createAirport(String n); //signature methods implemented by sub classes
void createAirline(String n);
void createFlight(String aname,String orig,String dest,int year,int month,int day,String id);
void createSection(String air,String fiiD,int rows,int cols,SeatClass s);
void findAvaliableFlights(String orig,String dest);
void bookSeat(String air,String fl,SeatClass s,int row,char col);
void displaySystemDetails();
}
class Airport extends SystemManager
{
String name;
public void createAirport(String n)
{
name=n;
}
}
class Airline extends SystemManager
{
String name;
public void createAirline(String n)
{
name=n;
}
}
class Flight extends SystemManager //subclass Flight
{
String aname,orig,dest,id; //datamembers declaration
int year,int month,int day;
public void createFlight(String aname,String orig,String dest,int year,int month,int day,String id)//method with parameters
{
this.aname=aname; //assign each parameter to datamembers
this.orig=orig;
this.dest=dest;
this.year=year;
this.month=month;
this.day=day;
this.id=id;
}
}
class FlightSecton extends SystemManager
{
String air,fiiD;
int rows,int cols;
SeatClass s;
void createSection(String air,String fiiD,int rows,int cols,SeatClass s)
{
this.air=air;
this.fiiD=fiiD;
this.rows=rows;
this.cols=cols;
this.s=s;
}
}
class Seat extends SystemManager //create seat class
{
boolean status; //data members
String air,fl;
SeatClass s;
int row;
char col;
void bookSeat(String air,String fl,SeatClass s,int row,char col) //method with parameters
{
this.air=air;
this.fl=fl;
this.s=s;
this.row=row;
this.col=col;
status=true;
}
}
class ABSSystem
{
public static void main(String args[])
{
//create all objects of classes and call methods
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.