Create a class movie for ticket booking with data members theatrename, date, moviename, screenno, amount, no_of_tickets and total_amount and include functions reservation() , bookiing_details().
Create dynamic object and display ticket booking details.
#include <iostream>
using namespace std;
class Date{
int day, month, year;
public:
Date(){}
Date(int day, int month, int year){
this->day = day;
this->month = month;
this->year = year;
}
void display(){
cout<<this->day<<"/"<<this->month<<"/"<<this->year;
}
};
class Movie{
string theatrename, moviename;
int screenno, amount, no_of_tickets, total_amount;
Date date;
public:
Movie(string name, string theatre, int amount){
this->moviename = name;
this->theatrename = theatre;
this->amount = amount;
}
void reservation(int tickets, Date date){
this->no_of_tickets = tickets;
this->date = date;
this->total_amount = this->no_of_tickets * this->amount;
}
void booking_details(){
cout<<"Movie: "<<this->moviename<<endl;
cout<<"Date: "; this->date.display(); cout <<endl;
cout<<"Number of tickets: "<<this->no_of_tickets<<endl;
cout<<"Cost per ticket: "<<this->amount<<endl;
cout<<"Total cost: "<<this->total_amount<<endl;
}
};
int main(){
Movie *Avengers = new Movie("Avengers", "Opera", 100);
Avengers->reservation(3, Date(21, 4, 2021));
Avengers->booking_details();
return 0;
}
Comments
Leave a comment