Make a class diagram of your Design.  Code: The code is as follows. Date.h #define DATE_H #include using namespace std; class Date {     public:     std::string depart_date;     std::string arrival_date;        Date()    {        depart_date = "12-03";        arrival_date = "12-03";    }        void setDepartureDate(string d)    {        depart_date = d;    }        std::string getDepartureDate()    {        return depart_date;    }        void setArrivalDate(string a)    {        arrival_date = a;    }        std::string getArrivalDate()    {        return arrival_date;    }          };   Time.h #define TIME_H class Time {     public:     int depart_h, depart_m;     float arrival_h, arrival_m;          Time()     {         depart_h = 12;         depart_m = 20;         arrival_h = 2;         arrival_m = 50;     }          void setDepartureHour(int dh)     {         depart_h = dh;     }          int getDepartureHour()     {         return depart_h;     }          void setDepartureMin(int dm)     {         depart_m = dm;     }          int getDepartureMin()     {         return depart_m;     }          void setArrivalHour(int ah)     {         arrival_h = ah;     }          int getArrivalHour()     {         return arrival_h;     }          void setArrivalMin(int am)     {         arrival_m = am;     }          int getArrivalMin()     {         return arrival_m;     }      };     Flight class and main() method #include #include #include "Date.h" #include "Time.h" using namespace std; class Flight {     public:     int flightID;     int total_seats;     int reserved_seats;     bool isDirect;          Date d;     Time t;          Flight()     {         flightID=0;         total_seats=0;         reserved_seats=0;         isDirect = false;     }          void setFlightId(int id)     {         flightID = id;     }          int getFlightId()     {         return flightID;     }          void setTotalSeats(int t)     {         total_seats = t;     }          int getTotalSeats()     {         return total_seats;     }          void setReservedSeats(int r)     {         reserved_seats = r;     }          int getReservedSeats()     {         return reserved_seats;     }          void setIsFlightDirect(bool b)     {         isDirect = b;     }          bool getIsFlightDirect()     {         return isDirect;     }          void delayFlight(int min)     {         t.arrival_m = t.arrival_m + min;                  if(t.arrival_m > 59)         {             t.arrival_h = t.arrival_h + 1;             if(t.arrival_h > 12)             {                 t.arrival_h = t.arrival_h - 12;             }                          t.arrival_m = t.arrival_m - 60;         }                  std::cout << "Arrival time updated!" << std::endl;     }          void reserveSeat(int n)     {         reserved_seats = reserved_seats + n;         if(reserved_seats > total_seats)         {             std::cout << "Sorry! Seats are not available!" << std::endl;             reserved_seats = reserved_seats - n;         }         else         {             std::cout << "Seats reserved successfully!" << std::endl;         }              }          void display()     {         std::cout << "Flight Details" << std::endl;         std::cout << "Flight ID: " << getFlightId() << endl;           cout << "Departure date: " << d.getDepartureDate() << std::endl;         std::cout << "Departure time: " << t.getDepartureHour() << " hours and " << t.getDepartureMin() << " minutes." << std::endl;         cout << "Arrival date: " << d.getArrivalDate() << std::endl;         std::cout << "Arrival time: " << t.getArrivalHour() << " hours and " << t.getArrivalMin() << " minutes." << std::endl;              }      }; int main() {     Flight f;          f.setFlightId(1);     f.setIsFlightDirect(true);     f.setTotalSeats(100);     f.setReservedSeats(90);          int m;     std::cout << "Enter the delay in flight in minutes: ";     std::cin >> m;     f.delayFlight(m);          int s;     std::cout << "Enter the number of seats to be reserved: ";     std::cin >> s;     f.reserveSeat(s);          f.display();          return 0; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Make a class diagram of your Design. 

Code:

The code is as follows.

Date.h

#define DATE_H

#include <string>

using namespace std;

class Date
{
    public:
    std::string depart_date;
    std::string arrival_date;
   
   Date()
   {
       depart_date = "12-03";
       arrival_date = "12-03";
   }
   
   void setDepartureDate(string d)
   {
       depart_date = d;
   }
   
   std::string getDepartureDate()
   {
       return depart_date;
   }
   
   void setArrivalDate(string a)
   {
       arrival_date = a;
   }
   
   std::string getArrivalDate()
   {
       return arrival_date;
   }
   
    
};

 

Time.h

#define TIME_H

class Time
{
    public:
    int depart_h, depart_m;
    float arrival_h, arrival_m;
    
    Time()
    {
        depart_h = 12;
        depart_m = 20;
        arrival_h = 2;
        arrival_m = 50;
    }
    
    void setDepartureHour(int dh)
    {
        depart_h = dh;
    }
    
    int getDepartureHour()
    {
        return depart_h;
    }
    
    void setDepartureMin(int dm)
    {
        depart_m = dm;
    }
    
    int getDepartureMin()
    {
        return depart_m;
    }
    
    void setArrivalHour(int ah)
    {
        arrival_h = ah;
    }
    
    int getArrivalHour()
    {
        return arrival_h;
    }
    
    void setArrivalMin(int am)
    {
        arrival_m = am;
    }
    
    int getArrivalMin()
    {
        return arrival_m;
    }
    
};

 

 

Flight class and main() method

#include <stdio.h>
#include <iostream>

#include "Date.h"
#include "Time.h"

using namespace std;

class Flight
{
    public:
    int flightID;
    int total_seats;
    int reserved_seats;
    bool isDirect;
    
    Date d;
    Time t;
    
    Flight()
    {
        flightID=0;
        total_seats=0;
        reserved_seats=0;
        isDirect = false;
    }
    
    void setFlightId(int id)
    {
        flightID = id;
    }
    
    int getFlightId()
    {
        return flightID;
    }
    
    void setTotalSeats(int t)
    {
        total_seats = t;
    }
    
    int getTotalSeats()
    {
        return total_seats;
    }
    
    void setReservedSeats(int r)
    {
        reserved_seats = r;
    }
    
    int getReservedSeats()
    {
        return reserved_seats;
    }
    
    void setIsFlightDirect(bool b)
    {
        isDirect = b;
    }
    
    bool getIsFlightDirect()
    {
        return isDirect;
    }
    
    void delayFlight(int min)
    {
        t.arrival_m = t.arrival_m + min;
        
        if(t.arrival_m > 59)
        {
            t.arrival_h = t.arrival_h + 1;
            if(t.arrival_h > 12)
            {
                t.arrival_h = t.arrival_h - 12;
            }
            
            t.arrival_m = t.arrival_m - 60;
        }
        
        std::cout << "Arrival time updated!" << std::endl;
    }
    
    void reserveSeat(int n)
    {
        reserved_seats = reserved_seats + n;
        if(reserved_seats > total_seats)
        {
            std::cout << "Sorry! Seats are not available!" << std::endl;
            reserved_seats = reserved_seats - n;
        }
        else
        {
            std::cout << "Seats reserved successfully!" << std::endl;
        }
        
    }
    
    void display()
    {
        std::cout << "Flight Details" << std::endl;
        std::cout << "Flight ID: " << getFlightId() << endl;

 

        cout << "Departure date: " << d.getDepartureDate() << std::endl;
        std::cout << "Departure time: " << t.getDepartureHour() << " hours and " << t.getDepartureMin() << " minutes." << std::endl;

        cout << "Arrival date: " << d.getArrivalDate() << std::endl;
        std::cout << "Arrival time: " << t.getArrivalHour() << " hours and " << t.getArrivalMin() << " minutes." << std::endl;
        
    }
    
};


int main()
{
    Flight f;
    
    f.setFlightId(1);
    f.setIsFlightDirect(true);
    f.setTotalSeats(100);
    f.setReservedSeats(90);
    
    int m;
    std::cout << "Enter the delay in flight in minutes: ";
    std::cin >> m;
    f.delayFlight(m);
    
    int s;
    std::cout << "Enter the number of seats to be reserved: ";
    std::cin >> s;
    f.reserveSeat(s);
    
    f.display();
    
    return 0;
}

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education