0
試圖保持主體儘可能簡單,但無法使其工作。在代碼中,main中有一個switch語句,但是我需要將switch語句中的每個case放入單獨的函數中。請幫忙!集團項目影院座位開關聲明
choice = menu();
switch(choice)
{
case 1:
cout <<"Seating Prices\n\n";
for(int count=0;count<ROWS; count++)
{
cout <<"The price for row " << (count+1) <<": $";
cout <<price[count] <<endl;
getch();
}
break;
case 2:
cout <<"Purchase Tickets\n\n";
do
{
cout <<"Please enter the row: ";
cin >>rowChoice;
cout <<"Please enter the seat: ";
cin >>seatChoice;
if(seating[rowChoice][seatChoice] == '*')
{
cout <<"That seat is unavailable please make another selection.\n";
}
else
{
cost = price[rowChoice] + 0;
total += cost;
cout <<"Ticket price: " <<cost <<endl;
cout <<"Please confirm your purchase. Enter 1 for yes, 2 for no.";
cin >>confirm;
if(confirm==1)
{
cout <<"Your ticket purchase has been confirmed.\n";
seating[rowChoice][seatChoice] = TAKEN;
ticketSales++;
}
else if (confirm==2)
{
cout <<"Would you like to purchase another ticket? Enter 1 for yes, 2 for no." <<endl;
cin >>quit;
}
cout <<"Would you like to purchase another ticket? Enter 1 for yes, 2 for no.";
cin >>quit;
}
}
while (quit==1);
break;
case 3:
int viewRow;
cout <<"View Seats by Row\n\n";
cout <<"Enter the row you would like to view";
cin >>viewRow;
seatingChartRow(viewRow);
cout <<"Press 1 to return to the main menu.";
cin >>quit;
break;
case 4:
cout <<"Sales Statistics\n\n";
saleStats();
break;
case 5:
cout <<"Quit\n";
break;
default: cout <<"Error Input\n";
}
}
「_C could not't to it work_」並不是真正的問題報告。你在期待什麼?你有什麼? – Rook 2014-11-22 14:42:34
當我在主要的switch語句中工作正常。但是,如果我將它放在單獨的函數中,如果失敗了。我不知道我是否調用了錯誤的函數,搞亂了其他函數的定義。 – 2014-11-22 20:22:25