Professional Documents
Culture Documents
TITLE
DESCRIPTION
In this assignment you are and write a set of Java classes that simulate the
operation of an airline. An airline operates over a number of different
routes and uses a number of different aircraft types on each route. In this
assignment we will restrict the number of routes per airline to 10, and the
number of aircraft per route to 10. You are required to create three Java
classes, Airline, Route and Aircraft. A class called Assign1, which is the
driver class, has been supplied with this assignment.
Each of these three classes will have a constructor method which has a
signature identical to that used for that class in the Assign1 class. Each
will also have a toString() method that will return a String that can be
used to display information about the object.
Class data members should be private with appropriate setter and getter
methods for those that need to be accessed.
You must also produce UML class diagrams showing class relationships
and Object diagrams for the airline, its Hong Kong route and the aircraft
it uses on this route. These diagrams must be produced in a software
format that can be read by Microsoft Word. (No other format will be
accepted.)
Aircraft
An aircraft class has the following data members.
Data members
String type a design of the aircraft type eg. Boeing 747
int passengers the number of passengers that aircraft can carry
int crew the number of crew members needed
double maintCost the cost of maintenance per hour of flying
double fuelEffic the tonnes of fuel used per hour of flight
Page 1 of 5
Methods
1. A constructor method that accepts values for, and initialises all the
data members of an Aircraft object.
eg. Aircraft A330 = new Aircraft ("Airbus A330",
220,14,600,4.0);
Aircraft(type,passegers,crew,maintcosts/h,fueleff
ic);
To calculate these we assume all aircrew are paid $100 per hour in flight
and the cost of jet fuel is $767 per tonne. To this we add the hourly
maintenance costs and an overhead figure of $8000 to cover the costs
associated with buying a plane and the costs of administration and
infrastructure required on the ground.
Route
We assume all routes start in Adelaide. The Route class has the following
data members.
Data members
String destination eg “Hong Kong”
double flyTime the hours taken to reach the destination.
(Most jets fly at similar speeds so the time is the same for a given route)
int passengerVol passengers flying on this route each day
double fare We assume all passengers pay the same fare.
Aircraft [] planes An array of aircraft objects that have been
assigned to that route.
Methods
Page 2 of 6
1. A constructor that accepts values for and initialises destination, flyTime
and
passengerVol for the route.
Airline
Data members
String name
Route [] routes An array of Routes
Methods
Dingo Air
Adelaide - Hong Kong, 9.5 hours, 300
passengers
Page 3 of 6
Airbus A330, 220
Boeing 737, 150
Assign1
This class is provided for you below. It is the driver class for this
assignment as it is the only class that has a main method. In it, several
Aircraft objects, Route objects and an Airline object are created. Methods
are used to assign aircraft to Routes and Routes to an Airline. Methods of
the airline are used to display the Airline and calculate its daily profit.
Your code should include appropriate comments. Both code and diagrams
should include your name and email ID as well as the statement
Assign1.java
import java.text.*;
public class Assign1
{
public static void main (String [] args)
{
Assign1 a1 = new Assign1();
a1.runAirline();
}
public void runAirline()
{
NumberFormat cf= NumberFormat.getCurrencyInstance();
Page 4 of 6
//--- Create Aircraft objects --------
Aircraft A330 = new Aircraft ("Airbus A330",
220,14,600,4.0);
Aircraft B747 = new Aircraft ("Boeing 747",
350,20,1000,7.0);
Aircraft B737 = new Aircraft ("Boeing 737",
150,7,450,2.5);
Aircraft BAe464 = new Aircraft ("BAe 464", 60,4,300,1.3);
HNK.addAircraft(A330);
HNK.addAircraft(B737);
SNG.addAircraft(B747);
SNG.addAircraft(B737);
AUC.addAircraft(A330);
AUC.addAircraft(A330);
PER.addAircraft(B737);
PER.addAircraft(B737);
MTG.addAircraft(BAe464);
Page 5 of 6
}
}
Output of Assign1.java
Route Costs
HNK : $229,287.25
SNG : $205,773.75
AUC : $104,544.00
PER : $77,472.50
MTG : $7,272.83
Dingo Air
Adelaide - Hong Kong, 9.5 hours, 300 passengers
Airbus A330, 220
Boeing 737, 150
Adelaide - Singapore, 7.5 hours, 500 passengers
Boeing 747, 350
Boeing 737, 150
Adelaide - Auckland, 4.0 hours, 400 passengers
Airbus A330, 220
Airbus A330, 220
Adelaide - Perth, 3.5 hours, 270 passengers
Boeing 737, 150
Boeing 737, 150
Adelaide - Mt Gambier, 0.75 hours, 45 passengers
BAe 464, 60
You have to prepare pseudocode or flowchart before start writing the code.
(using Microsoft word or other drawing programs).
Page 6 of 6