Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description of the application The code is a slice of a larger application that sells tickets for airline fights. The first slice developed includes only

Description of the application
The code is a slice of a larger application that sells tickets for airline fights. The first slice
developed includes only the classes required to perform the very specific tasks of issuing a ticket,
assigning a seat to a passenger, and building up the manifest (or list of passengers) on a specific
flight.
Your starting position is a prototype that has a very simple command line interface so that the
complications of a Web application or graphical user interface are eliminated. Most of the
classes and associations between classes are shown in the class diagrams on page 3.
Business rules
There are two classes of seats: Economy and Business.
A business class ticket costs $750 and an economy seat costs $500.
Passengers may be frequent flyers, airline employees (but not both) or neither.
Airline employees get a 50% discount on economy seats, but not on business class seats.
Frequent flyers get no discount but have privileges outside the scope of this slice of the
application.
Notes
For this slice of the application, passengers have already selected a specific flight and day.
Invoicing and payment processing are handled by a separate subsystem.
For simplicity, the test airplane has very limited seating of only 14 seats.
Row 1 is business class and has one seat on either side of the aisle: 1A and 1B. Rows 2,3
and 4 are economy class and have two seats on either side of the aisle: A, B, C, and D.
No persistent data (databases) is used.
All output goes to the console (command line I/O). The placeholder classes Manifest and
UserPrompter will be replaced by a GUI user interface at a later time in development.
COMP311 Assignment 2: Debugging exercise
Page 2 of 3
What the provided code should do (requirements):
The Manifest class is the main program for this slice of the application.
User interface asks each passenger whether (s)he want to purchase a ticket. If the answer is
no the program stops as this situation simulates end of ticket sales.
The UI first asks whether the passenger wants business class and then, if no, economy class
The UI asks for the passenger name and whether the passenger is a frequent flyer or member
of the airline staff.
At this point, the UI invokes the core business logic to sell a ticket.
The application should check whether a suitable seat is available. Passengers cannot choose
their seat: the application assigns one. It issues a ticket and calculates the ticket price. Then it
prints out the ticket details.
Before ending, the Manifest class prints a list of all seats followed by the name of the
passenger who owns a ticket for that seat or the word Available if the seat was not sold.
Notes:
The seating plan is generated by the constructor of the SeatingPlan class and can be modified
easily by changing the enumeration type SeatingClass. You can assume these two classes have
already been tested and have no errors. In other words, dont worry if you dont understand their
code.
Instructions
You are given a JAR that contains source code.
1. Import the Java source into Eclipse. Follow instructions from the instructor if you are not
familiar with Eclipse
2. Run the program a few times to see how it works. You should see clear evidence of bugs.
3. Use the debugger to trace what is going wrong. Resist the temptation to just read the code
looking for bugs. The instructor will walk you through using the debugger to determine
what code causes at least one of the problems.
4. Continue to debug and fix bugs as you go until you are satisfied you have done all that
you can with this code.
FrequentFlyer.class:
package com.cc.airline.passengers;
public class FrequentFlyer extends Passenger {
private String fFlyerId;
public FrequentFlyer( PassengerName pName, String fFlyerId){
super(pName);
this.fFlyerId = fFlyerId;
}
public String getFFlyerId(){
return fFlyerId;
}
public void setFFlyerId(String flyerId){
fFlyerId = flyerId;
}
}
Passenger.class
package com.cc.airline.passengers;
public class Passenger {
private PassengerName pName;
public Passenger(){
this.pName = new PassengerName("T.","B.","A.");
}
public Passenger(PassengerName pName){
this();
this.pName = pName;
}
public PassengerName getPName(){
return pName;
}
public void setPName(PassengerName name){
pName = name;
}
}
PassengerName.class
package com.cc.airline.passengers;
public class PassengerName {
private String firstName;
private String lastName;
private String mInitial;
public PassengerName(String first, String middle, String last){
firstName = first;
mInitial = middle;
lastName = last;
}
public PassengerName(String first, String last){
firstName = first;
lastName = last;
}
public String toString(){
String name = firstName;
if (mInitial != null && mInitial.length()>0){
name +=""+ mInitial;
}
return name +""+ lastName;
}

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

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

What are some strategies for reducing car dependence within cities?

Answered: 1 week ago