Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include using namespace std; class Movie { public: Movie(string name = , int min = 0) { setData(name, min); } void setData(string name,

#include #include using namespace std;

class Movie { public: Movie(string name = " ", int min = 0) { setData(name, min); }

void setData(string name, int min) { movieName = name; length = min; } void printData() const { cout << "Movie: " << movieName << ", Movie Duration: " << length << " minutes "; }

string getMovieName() const { return movieName; }

int getMinutes() const { return length; }

private: string movieName; int length; };

// TODO: Overload the operators >, >=, <, and <= in the Flight class. // Ensure support for comparing Flight objects to Flight objects, // Flight objects to Movie objects, and Movie objects to Flight objects. // 12 functions in total

class Flight { public: Flight(int flightNum = 0, int min = 0) { setData(flightNum, min); }

void setData(int flightNum, int min) { flightNumber = flightNum; length = min; }

void printData() const { cout << "Flight Number: " << flightNumber << " Flight Duration: " << length << " minutes "; }

int getMinutes() const { return length; }

int getFlightNumber() const { return flightNumber; }

private: int flightNumber; int length; };

int main() { Flight f1(1298, 101); Flight f2(9821, 125); Movie m1("The Avengers", 101); f1.printData(); f2.printData(); m1.printData(); if (m1 > f1) cout << m1.getMovieName() << " is longer than Flight " << f1.getFlightNumber() << endl; if (m1 < f1) cout << m1.getMovieName() << " is shorter than Flight " << f1.getFlightNumber() << endl; if (m1 < f2) cout << f2.getFlightNumber() << " is shorter than Flight " << m1.getMovieName() << endl; if (m1 > f2) cout << m1.getMovieName() << " is longer than Flight " << f2.getFlightNumber() << endl; if (f1 >= m1) cout << "Flight " << f1.getFlightNumber() << " is longer than or equal to " << m1.getMovieName() << endl; if (f1 <= m1) cout << "Flight "<< f1.getFlightNumber() << " is shorter than or equal to " << m1.getMovieName() << endl; if (f2 <= m1) cout << "Flight " << f2.getFlightNumber() << " is shorter than or equal to " << m1.getMovieName() << endl; if (f2 >= m1) cout << "Flight "<< f2.getFlightNumber() << " is longer than or equal to " << m1.getMovieName() << endl; if (f1 >= f2) cout << "Flight " << f1.getFlightNumber() << " is longer than or equal to Flight " << f2.getFlightNumber() << endl; return 0; }

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

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

Students also viewed these Databases questions

Question

Describe ERP and how it can create efficiency within a business

Answered: 1 week ago