Could someone please tell me how to solve this because i was not able to get the idea of using arrays in classes
Here is the Question :
The PVR Cinemas manager approaches you to develop a system for ticket booking. It has 5 screens each with a capacity of 500 seats of which 100 are platinum, 100 are diamond and 300 are gold. The cost of platinum, diamond and gold tickets are Rs.150, Rs.125, and Rs.100 respectively.
• Construct a class to model a screen with an array of integers for each category of seats. Provide a constructor to initialize the array to 0.
• Include a member function bookSeat() that gets the category of the seat and number of tickets to be booked and then prints the seat numbers. The booked seats are marked by 1. If no seats are available then your program should display appropriate message.
Test the above class with a main program that creates an array of objects (size of array depends on the number of screens) and display the total amount to be paid by the visitor.
It looks like you only need fixed-size arrays as class members, which simplifies things for you. I'm not going to summarize the whole problem, and nobody is going to do your work for you, but I will help you understand it.
What's the first part of the problem you're struggling with?
#include<iostream>
#include<conio.h>
#include<string>
usingnamespace std;
class cinema
{
private:
int n1,n2,a[100],b[100],i,pt,dd;
public:
void platinum()
{
cout<<"\nPlease Enter the Number of Tickets ";
cin>>n1;
for(i=pt;i>=pt+n1;i++)
a[i]=1;// The arrays seems not to be intilizing with the value
pt+=n1; //Here, some garbage value is printing
cout<<"\nTickets left "<<100-pt;
}
void diamond()
{
cout<<"\nPlease Enter the Number of Tickets ";
cin>>n2;
for(i=dd;i>=dd+n2;i++)
b[i]=1;
//cout<<b[gd]<<endl;
dd+=n2;
cout<<"\nTickets left "<<100-dd;
}};
int main()
{
int n;
cinema a;
while(1)
{
cout<<"\nPlease enter your choice, for platinum 1; for diamond 2; ";
cin>>n;
switch(n)
{
case 1:
{a.platinum();
break;}
case 2:
{ a.diamond();
break;
}}
}
getch();
}