-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLongHaulFlight.java
More file actions
63 lines (53 loc) · 2.04 KB
/
LongHaulFlight.java
File metadata and controls
63 lines (53 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//Sina Pahlavan
//501 034 271
/*
* A long haul flight is a flight that travels thousands of kilometers and typically has separate seating areas
*/
public class LongHaulFlight extends Flight
{
int numFirstClassPassengers;
String seatType;
// Possible seat types
public static final String firstClass = "First Class Seat";
public static final String economy = "Economy Seat";
public LongHaulFlight(String flightNum, String airline, String dest, String departure, int flightDuration, Aircraft aircraft)
{
// use the super() call to initialize all inherited variables
// also initialize the new instance variables
super(flightNum,airline,dest,departure,flightDuration,aircraft);
seatType = economy;//set seat type to economy
numFirstClassPassengers = 0;//set number of passengers to 0.
}
public LongHaulFlight()
{
// default constructor
this.flightNum = "AC100";
this.airline = "Air Canada";
this.dest = "New York";
this.origin = "Toronto";
this.departureTime = "22:30";
this.flightDuration = 150;
this.aircraft = new Aircraft(300,0,"Boeing 737");
this.seatType = economy;
this.numFirstClassPassengers = 0;
}
// return the total passenger count of economy passengers *and* first class passengers
// use instance variable at top and inherited method that returns economy passenger count
public int getPassengerCount()
{
/**
* the total number of first class students is added to the inherited method get passengers which returns the
* number of economy passengers
*/
return numFirstClassPassengers+super.getPassengers();
}
public String toString(){
/**
* overrides toString() from flight
* adds the phrase ' long haul' to the end
* returns a string version of the flight
*/
return airline + "\t Flight: " + flightNum + "\t Dest: " + dest + "\t Departing: " + departureTime + "\t Duration: " + flightDuration + "\t Status: " + status + " Long haul";
}
public FlightType getFlightType(){return FlightType.LONGHAUL;}//overriding the getFlightType from flight so that it returns longhaul
}