Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
12 views

Task 4 Lab 10.cpp

Uploaded by

latif qasim
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Task 4 Lab 10.cpp

Uploaded by

latif qasim
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <iostream>

using namespace std;

class Rental;

class Movie {
string title, genre, director;

friend class Rental;


public:
void set_title( const string title ) { this->title = title; }
void set_genre( const string genre ) { this->genre = genre; }
void set_director( const string director ) { this->director = director; }

string get_title() const { return this->title; }


string get_genre() const { return this->genre; }
string get_director() const { return this->director; }

};

class Customer {
int id;
string name;

friend class Rental;


public:
void set_id( const int id ) { this->id = id; }
void set_name( const string name ) { this->name = name; }

int get_id() const { return this->id; }


string get_name() const { return this->name; }

};

class Rental {
Movie movie;
Customer customer;
public:
void set_movie( const Movie movie )
{
this->movie = movie;
}
void set_customer( const Customer customer )
{
this->customer = customer;
}

Movie get_movie() const { return this->movie; }


Customer get_customer() const { return this->customer; }
friend ostream& operator <<( ostream &output, const Rental &rental );

};

ostream& operator <<( ostream& output, const Rental &rental )


{
output << "Movie Details:\n\tMovie name: " << rental.movie.get_title() << "\n\
tGenre: " << rental.movie.get_genre() << "\n\tDirector: " <<
rental.movie.get_director() << "\nCustomer Details:\n\rName: " <<
rental.customer.get_name() << "\n\tID: " << rental.customer.get_id() << endl;
return output;
}

int main ()
{
Movie movie_1, movie_2, movie_3;

movie_1.set_title("Dune Part Two");


movie_1.set_genre("Science Fiction");
movie_1.set_director("Denis Villeneuve");

movie_2.set_title("Get Out");
movie_2.set_director("Jordan Peele");
movie_2.set_genre("Horror");

movie_3.set_title("Inception");
movie_3.set_genre("Thriller");
movie_3.set_director("Christopher Nolan");

Customer customer_1, customer_2;

customer_1.set_name("Atif Aslam");
customer_1.set_id(1);

customer_2.set_name("Bushra Ansari");
customer_2.set_id(2);

Rental rental_1, rental_2, rental_3;


rental_1.set_movie(movie_1);
rental_1.set_customer(customer_1);
rental_2.set_movie(movie_2);
rental_2.set_customer(customer_2);
rental_3.set_movie(movie_3);
rental_3.set_customer(customer_1);

cout << rental_1 << '\n' << rental_2 << '\n' << rental_3 << endl;

You might also like