Answered step by step
Verified Expert Solution
Question
1 Approved Answer
write the code in object oriented programming c++ you should modify this code such that the passenger array you created inside the flight should be
write the code in object oriented programming c++
QUESTION 1: Implement class MyDate that represents the date, this class should: 1) Encapsulate information about the day, month, year, 2) Forbid invalid dates, where the following criteria should be considered: - Days are in the range [131]. - Months are in the range [112]. - Years are not less than 1900. If any forbidden value entered, you should set the value to default value. 3) Two different constructors (defaulted and parameterized) 4) Appropriate setters and getters for the encapsulated information (data members) Test your class with a simple driver that defines a valid and an invalid date. Use separate implementation. \#ifndef MYDATE_H \#define MYDATE_H using namespace std; class MyDate \{ private: static const int DEFAULT_DAY =1; static const int DEFAULT_MONTH =1; static const int DEFAULT_YEAR =1900; int day; int month; int year; bool isvalidDate(int d, int m, int y) const; public: MyDate () ; MyDate(int d, int m, int y ); void setDate(int d, int m, int y ); int getDay() const; int getMonth() const; int getYear() const; \}; \#endif \#include "MyDate.h" \#include bool MyDate: isvalidDate(int d, int m, int y) const \{ if (y12d \#include using namespace std; class Passenger \{ private: const string firstName; const string lastName; const string dateofBirth; const string nationality; const int id; public : Passenger(const string\& firstName, const string\& lastName, const string\& dateofBirth, const string\& nationality, int id); const string\& getFirstName() const; const string\& getLastName() const; const string\& getDateofBirth() const; const string\& getNationality() const; int getID() const; void printDetails() const; \}; \#endif \#include "Passenger.h" Passenger::Passenger(const string\& firstName, const string\& lastName, const string\& dateofBirth, const string\& nationality, int id) : firstName(firstName), lastName(lastName), dateofBirth(dateofBirth), nationality (nationality), id(id) \{\} const string\& Passenger::getFirstName() const \{ return firstName; \} const string\& Passenger::getLastName() const \{ return lastName; \} const string\& Passenger::getDateofBirth() const \{ return dateofBirth; \} const string\& Passenger::getNationality() const \{ return nationality; \} int Passenger::getID() const \{ return id; \} void Passenger::printDetails() const \{ cout " you should modify this code such that the passenger array you created inside the flight should be converted into a dynamically allocated array. Add a setter, a default constructor, and a destructor. Also, modify the existing constructors, parameterized and copy constructors.
_______________________________________
_______________________________________
_______________________________________
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