Answer to Question #182437 in C++ for P. Gokul

Question #182437

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.


1
Expert's answer
2021-04-21T05:25:12-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS