QUESTION: You will use OOP to model flights, where: ► Each Flight has a number, date, time, departure airport, destination airport, and a number of passengers. ► Each Passenger has a name, nationality, date of birth, and a passport number. ► Each Date has a day, month and year. ► Each Time has an hour, minute and second The following class diagram shows the four classes to be used and the relationship between them. The diamond indicates a has-a relationship. Passenger Date Flight Time Class Time Princess Sumaya University for Technology King Hussein School for Information Technology Computer Science Department Object Oriented Programming Lab CS11253-Spring 2021/2022 Lab Assignment #7 Implement in time.h a class named Time for representing the time of a certain event. • Data Members. Each Time object stores the hour, minute and second as unsigned int. • Constructors. The class has only one constructor that receives the hour, minute and second as arguments. The default value for the hour, minute and second is e. • Validation. Set the hour to 23 if it is greater than 23 and the minute and second to 59 if it is greater than 59. • Member Functions. o Provide getters for each of the data members. A print() function that prints the time in the following format: hour:minute: second. If the hour, minute or second is less than 10, it must be preceded by a e. For example: 01:09:08 The class has no setter functions.
Class Date Implement in date.h a class named Date for representing dates. • Data Members. Each Date object stores the day, month and year as unsigned int. • Constructors. The class has only one constructor that receives the day, month and year as arguments. The default value for the day and the month is 1 and for the year is 1900 • Validation. The constructor must validate the received day, month and year: Set the month to 12 if the received month is greater than 12. Set the day to 28 if the month is February and the day is greater than 28. • Set the day to 31 if the month is January, March, May, July, August, October or December and the day is greater than 31. Otherwise, set the day to 30 if it is greater than 30. • Member Functions. o Provide getters for each of the data members. • A print() function that prints the date in the following format: day/month/year o The class has no setter functions.
Class Passenger Implement in passenger.h a class named Passenger for representing an airplane passenger. • Data Members. Each Passenger object stores the name, nationality and passport number of the passenger as string and the date of birth of the passenger as an object of type Date. • Constructors. The class has: o A default constructor. Initialize the data members to whatever default values you like. o A parameterized constructor that receives all the data members as required arguments. o You must use an initializer list in each of the above two constructors. • Member Functions. • Provide getters for each of the data members. Provide setters for each of the data members. A print() function that prints the details of the passenger in the following format: [name] from [nationality] (passport no. (passpot number], DoB: [date of birth]) The following are examples: Ahmad Hamdi from Egypt (passport no. E9987, DOB: 1/1/2020) Hamdah Hamdan from Palestine (passport no. P1937, DOB: 2/2/1999) Salameh Salem from Jordan (passport no. 39987, Dob: 1/12/1987) Jamilah Bou Jamal from Algeria (passport no. A9991, DOB: 13/11/1971) A Functions that do not modify any data member must be declared const. A Returned and passed Date objects from/to functions must be done using references to constant objects (const Date&).
Class Flight Implement in flight.h a class named Flight for representing an airplane flight. Each flight can take up to 200 passengers. The class must support public interface provided below. The choice of the appropriate data members is left to you. C 1 class Flight { 2 public: 3 // The only constructor 4 Flight(string origin, string destination, string number); 5 6 // get the departure date 7 const Date& get_date() const; 8 9 // get the departure time 10 const Time& get_time() const; 11 12 // get the departure airport 13 string get_origin() const ; 14 i Hints. - Each Flight object needs an array of Passenger objects of size 200. - You need to keep track of how many passengers have been added. Write a simple program in test.cpp that tests your implementation of class Flight. The program must do at least the following: • Define one Flight object with a flight number, an origin airport, a destination airport,
departure date and departure time of your choice. • Add to the flight at least 4 passengers of your choice. • Print the details of the flight and print the details of the passengers on the flight. The following is sample output of the program: Flight RJ-0987 From NY to AMM on 3/4/2021 at 01:02:03 Passengers: 1. Ibrahim Al Ibrahimi from Egypt (passport no. E9987, DOB: 1/1/2020) 2. Khaled Khalil from Palestine (passport no. P1937, DOB: 2/2/1999) 3. Salma Salam from Jordan (passport no. 39987, Dob: 1/12/1987) 4. Hala Hilal from Algeria (passport no. A9991, DOB: 13/11/1971)
QUESTION: You will use OOP to model flights, where: ► Each Flight has a number, date, time, departure airport, destinati
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
QUESTION: You will use OOP to model flights, where: ► Each Flight has a number, date, time, departure airport, destinati
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!