1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
A * * * * * * * * * * * * * * * * * * * *
B * * * * * * * * * * * * * * * * * * * *
C * * * * * * * * * * * * * * * * * * * *
D * * * * * * * * * * * * * * * * * * * *
E * * * * * * * * * * * * * * * * * * * *
F * * * * * * * * * * * * * * * * * * * *
G * * * * * * * * * * * * * * * * * * * *
H * * * * * * * * * * * * * * * * * * * *
I * * * * * * * * * * * * * * * * * * * *
J * * * * * * * * * * * * * * * * * * * *
K * * * * * * * * * * * * * * * * * * * *
L * * * * * * * * * * * * * * * * * * * *
M * * * * * * * * * * * * * * * * * * * *
N * * * * * * * * * * * * * * * * * * * *
O * * * * * * * * * * * * * * * * * * * *
P * * * * * * * * * * * * * * * * * * * *
S C R E E N
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
A * * * * * * * * * * * * * * * * * * * *
B * * * * * * * * * * * * * * * * * * * *
C * * * * * * x x x x x x x x * * * * * *
D * * * * * * * * * * * * * * * * * * * *
E * * * * * * * * * * * * * * * * * * * *
F * * * * * * * * * * * * * * * * * * * *
G * * * * * * * * * * * * * * * * * * * *
H * * * * * * * * * * * * * * * * * * * *
I * * * * * * * * * * * * * * * * * * * *
J * * * * * * * * * * * * * * * * * * * *
K * * * * * * * * * * * * * * * * * * * *
L * * * * * * * * * * * * * * * * * * * *
M * * * * * * * * * * * * * * * * * * * *
N * * * * * * * * * * * * * * * * * * * *
O * * * * * * * * * * * * * * * * * * * *
P * * * * * * * * * * * * * * * * * * * *
S C R E E N
i have to change the "*" to "x" like the above display example.
but its seems like i cant display the x..any body can help me?please..
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std; //used for cout and endl
void displayMenu()
{
system ("cls");
cout << " +-------------------------------------------+" << endl;
cout << " | cinema seating project |" << endl;
cout << " |===========================================|" << endl;
cout << " | Select : |" << endl;
cout << " | 1 => Seat assignment |" << endl;
cout << " | 2 => Payments (for reserved seats) |" << endl;
cout << " | 3 => Reset Seating Plan |" << endl;
cout << " |===========================================|" << endl;
cout << " | Q => Quit |" << endl;
cout << " +-------------------------------------------+" << endl;
cout << endl;
cout << " Choice : " ;
}
void displaySeat( char cinema[][20] ) //display seat
{
cout << endl;
cout << " door door "<< endl;
cout << "_____________| |__________________________________| |___________"<< endl;
cout << endl;
cout << endl;
cout <<"-------------------------------------------------------------------"<<endl;
cout << endl;
int row ;
int column;
for( int row = 0; row < 17; ++row )
for( int column = 0; column < 20; ++column )
{
cinema[row][column] = '*';
}
for(row = 0; row < 17 ; row++)
{
if( row == 7 || row == 13 ) //adds row spacers
cout << endl;
cout << char(bool(row)*32+' '+row) << " "; //gets rid of the char array of A B C...
for( column = 0; column < 20; column++ )
{
if(column == 0 || column == 4 || column == 16)
{
cout << " "; //adds column spacers
}
if( row == 0 ) //prints numbers along the topc
{
cout.width(2);
cout << column+1 << " ";
}
else
cout << " " << cinema[row][column] << " "; //prints each seat
}
cout << endl;
}
cout << endl;
cout << " |D|------------------------------------------------|D| "<<endl;
cout << " ______|O CINEMA SCREEN O|_____"<<endl;
cout << " O O "<<endl;
cout << " R R "<<endl;
cout << endl;
return;
}
void assignSeat(char cinema[][20]) // seat choose function
{
int i ; // row
int j; // column
char seatcol;
char more='Y';
do
{
cout<<" Please enter seat desired A-P :";
cin>>seatcol;
cout<<endl;
seatcol=toupper(seatcol);//change to upper case so that can always subtract 'A'
i=( seatcol-'A' ) + 2; //by subtracting A, it changes A to 0, B to 1, C to 2, D to 3
while(i>17||i<1)
{
cout << i << endl;
cout <<" invalid seat" << endl;
cout << " Enter Seat desired A-"<<(char)('A'-17)<<" : ";
cin >> seatcol;
seatcol=toupper(seatcol);
i = (seatcol-'A') + 2;
}
cout<<" Please enter the row number 1-20 :";
cin>>j;
cout<<endl;
while(j>=21||j<=0)
{
cout<<" invalid input of row,please enter again"<<endl;
cout<<" the row number 1-20 :";
cin>>j;
cout<<endl;
}
if( cinema[i][j]=='X')
cout<<" Seat already chosen-rechoose"<<endl;
}while (cinema[i][j]=='X');
cinema[i][j]='X';
return ;
}
int main ()
{
char choice;
bool done = false;
char cinemas[17][20];
do
{
displayMenu ();
cin >> choice;
choice = toupper (choice);
char more='Y';
switch (choice)
{
case '1' : displaySeat(cinemas);
while(left>0&&toupper(more)=='Y') // repeat function seating for next seat book
{
assignSeat(cinemas);
displaySeat(cinemas);
cout<<"choose another seat(Y/N)? ";
cin>>more;
}
system("pause");
break;
case '2' : cout << "Not yet implement" << endl;
system("pause");
break;
case '3' : cout << "Not yet implement" << endl;
system("pause");
break;
case 'Q' : done = true;
break;
default : cout << " Invalid selection, try again " << endl;
system ("pause");
break;
}
} while (!done) ;
cout << " thanks for using this program ! " << endl;
cout << endl;
return 0;
}