Answered step by step
Verified Expert Solution
Link Copied!

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++
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.
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
_______________________________________
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
_______________________________________
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
_______________________________________
image text in transcribed
image text in transcribed
image text in transcribed
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 "

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

Define market concentration and market spreading.

Answered: 1 week ago

Question

600 lb 20 0.5 ft 30 30 5 ft

Answered: 1 week ago