ok i have this code working
-but i have few more questions guys,
-i wanted to put error trapping in the seatRes() function but have no idea how,
-i also wanted to make a function that will be able to cancel a reserve seat, and change it to another seat
-i also want to put error trapping when choosing a seat that has already been taken
i read some topics here in the site but i got lost and dont fully understand the pointers and references
they also gave me an idea about the boolean thing, but i cant understand how will i make it work
can anyone guide me please?
#include <iostream>
#include <conio.h>
using namespace std;
int movieChoice;
int seatNum;
int seatPlan [5][10]={0};
int rows,cols;
char space;
void seatDisplay( int a[][10]);
void seatNew( int n[][10]);
void seatDisplay( int a[][10]){ //this function shows the seat plan
for (int i=0;i<5;i++){
for (int j=0;j<10;j++){
cout<<a[i][j];
cout<<" ";
}
cout<<endl;
}
}
void seatNew( int n[][10]){ // this function shows the reserved seats
for (int i=0;i<5;i++){
for (int j=0;j<10;j++){
cout<<n[i][j];
cout<<" ";
}
cout<<endl;
}
}
void seatRes(int x){ //this function reserves the seats
while (x>50 || x<=0){
cout<<"Cannot process Reservation."<<endl;
cout<<"Please Enter number of seats to be reserved: ";
cin>>x;
}
cout<<endl;
cout<<"Please enter seat row and column you wish to reserve: \n";
cout<<endl;
for (int i=1;i<=x;i++){
cout<<"(row,column): ";
cin>>rows>>space>>cols;
seatPlan[rows][cols]=1;
}
}
int priceComp(int y){ //this function computes and displays the ticket price
int price;
price=y*150;
cout<<endl;
cout<<"You have reserved "<<y<<" seat(s).";
cout<<endl;
cout<<endl;
cout<<"Ticket Price: "<<price<<endl;
cout<<endl;
return 0;
}
int main(){ //this is the main function
cout<<"Welcome to Movie World"<<endl;
cout<<endl;
cout<<"1 - Movie 1"<<endl;
cout<<"2 - Movie 2"<<endl;
cout<<"3 - Movie 3"<<endl;
cout<<endl;
cout<<endl;
cout<<"Enter your choice of Movie: ";
cin>>movieChoice;
cout<<endl;
switch (movieChoice){
case 1:
cout<<endl;
cout<<"Movie 1"<<endl;
cout<<endl;
cout<<"Seating Reservation"<<endl;
cout<<endl;
seatDisplay(seatPlan);
cout<<"How many seats would you like to reserve?: ";
cin>>seatNum;
seatRes(seatNum);
cout<<"Seating Reservation";
cout<<endl;
cout<<"1 marks your reserved seat \n";
cout<<endl;
cout<<"------Movie 1 SEAT PLAN----------- \n";
cout<<endl;
seatNew(seatPlan);
priceComp(seatNum);
break;
case 2:
cout<<endl;
cout<<"Movie 2"<<endl;
cout<<endl;
cout<<"Seating Reservation"<<endl;
cout<<endl;
seatDisplay(seatPlan);
cout<<"How many seats would you like to reserve?: ";
cin>>seatNum;
seatRes(seatNum);
cout<<"Seating Reservation";
cout<<endl;
cout<<"1 marks your reserved seat \n";
cout<<"------Movie 2 SEAT PLAN----------- \n";
cout<<endl;
seatNew(seatPlan);
priceComp(seatNum);
break;
case 3:
cout<<endl;
cout<<"Movie 3"<<endl;
cout<<endl;
cout<<"Seating Reservation"<<endl;
cout<<endl;
seatDisplay(seatPlan);
cout<<"How many seats would you like to reserve?: ";
cin>>seatNum;
seatRes(seatNum);
cout<<"Seating Reservation";
cout<<endl;
cout<<"1 marks your reserved seat \n";
cout<<"------Movie 3 SEAT PLAN----------- \n";
cout<<endl;
seatNew(seatPlan);
priceComp(seatNum);
break;
default:
cout<<endl;
cout<<"Invalid Input"<<endl;
}
return 0;
_getch();
}