Question
C++ classes and objects Define a class with name Airport with following members: a private attribute with the name of the airport as C++ string
C++ classes and objects
Define a class with name Airport with following members:
- a private attribute with the name of the airport as C++ string.
- a private attribute with name slot as array of pointers to Flights with 24 rows (for the hours of a day) and 60 columns (for the minutes of each hour of a day), getting initialised by null pointers (i.e. maximum 24*60 starts and landings each day; due to turbulences of the air and for security reasons at least one minute pause has to be in between two starts). In this array pointers to scheduled landings or starting flights in each minute of a day shall get stored.
- definition of a public constructor with a name as parameter to initialise the respective attribute.
- definition of a public destructor deleting the whole pointer array with all flight objects on heap.
- definition of a public function with name schedule having a LocalTime and a pointer to a flight as parameters without return value and storing the flight at the scheduled time slot.
- definition of a public function with name comment with a LocalTime and a string as parameters having no return value and storing the string as comment of the flight at this scheduled time slot.
- definition of a public function with name delay with two LocalTime parameters having no return value and storing the time in second parameter in the flight object at the scheduled time given in the first parameter.
- definition of a public function with name print with one parameter of above enumeration type from ArrivalDeparture for arrivals or departures without return value. In its body write a table of all stored arriving flights or starting flight given by the parameter value (see example below).
Then,
Write a C++ main function with following definitions and statements:
- Define an object of type Airport initialized with name DUSSELDORF AIRPORT.
- Successively send to this object appropriate messages with new objects of type Flight on heap and with the scheduled time as parameters including all example flight data shown below. Also send appropriate messages to store comments and delays as shown below. Only above defined constructors and member functions are allowed to be used and called, no further or changed member functions, constructors, additional or deleted parameters or changed visibilities of class member data.
- Send to the object for Dusseldorf airport a message print to output the table of arrivals and a second message to output all departures.
Code done:
#include
//subtask 1 enum TimeZone { ACT, CET, CST, EST, GMT, MSK, PST, UTC };
//subtask 2 enum ArrivalDeparture { arrival, departure };
//subtask 3 class LocalTime { private: int minutes; TimeZone tz; public: LocalTime() { minutes = -1; tz = CET; } LocalTime(int h, int m, TimeZone t) { set_time(h, m); t = CET; } void set_time(int h, int m) { if (h >=0 && m >=0) minutes = m+h*60; else minutes= -1; } int get_hour() { return minutes / 60; } int get_minute() { return minutes % 60; } bool is_valid() { return minutes >=0 ; } };
//subtask 4 ostream& operator
//subtask 5 class Flight { private: ArrivalDeparture arrivalOrDeparture; string code, destination, gate, checkIn, comment; LocalTime expected;
public: Flight(ArrivalDeparture,string ,string ,string ,string , string); ~Flight(); string get_code(); string get_destination(); string get_gate(); string get_checkIn(); string get_comment(); LocalTime get_expected(); void set_expected(LocalTime e); void set_comment(string c); bool is_arrival(); bool is_departure(); void print(LocalTime l); };
//subtask 6 Flight:: Flight (ArrivalDeparture a, string c, string d, string g, string ci, string co) { arrivalOrDeparture = a; code = c; destination = d; gate = g; checkIn = ci; comment = co = ""; } Flight :: ~Flight() {}
string Flight :: get_code() { return code; } string Flight :: get_destination() { return destination; } string Flight :: get_gate() { return gate; } string Flight :: get_checkIn() { return checkIn; } string Flight :: get_comment() { return comment; } LocalTime Flight :: get_expected() { return expected; } void Flight :: set_expected(LocalTime e) { expected = e; } void Flight :: set_comment(string c) { comment = c; } bool Flight :: is_arrival() { return arrivalOrDeparture == arrival; } bool Flight :: is_departure() { return arrivalOrDeparture == departure; } void Flight :: print(LocalTime l) { cout DUSSELDORF AIRPORT ARRIVALS =========================== Flight From LH 2010 Munich EW 9347 Manchester Scheduled Expected Gate Check-in Comments 12:40 13:05 A04 14:50 B04 DUSSELDORF AIRPORT DEPARTURES == = = = = = = == = = = = = = = = = = = = == = = = = = Flight To AF 1307 Paris SU 2537 Moscow EW 9466 London-Heathrow LH 2011 Munich XQ 959 Izmir Scheduled Expected Gate Check-in Comments 09:10 B51 192-194 departed 10:40 031 252-255 boarding 11:15 B35 151-170 13:25 A40 115-120 Code Sharing 14:55 15:20 045 240-242 flight AF 1307 deleted flight SU 2537 deleted flight EW 9466 deleted flight LH 2010 deleted flight LH 2011 deleted flight EW 9347 deleted flight XQ 959 deleted Local Time Flight Airport expected slot 24*60 - minutes : Integer + LocalTime() + void set_time() + get_hour() + get_minute() + is_valid() - name : String + Airport) + -Airport() + schedule() + comment) + delay() + print() zone > TimeZone ACT CET CST EST GMT MSK PST UTC - code : String - destination : String - gate : String - checkin : String - comment; String + Flight() +-Flight + get_code() + get_destination() + get_gate() + get_checkin() + get_comment() + get_expected() + set_comment() + set_expected() + is_arrival() + is_departure() + print() arrivalOrDeparture > ArrivalDeparture arrival departure
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started