No worries, I decided to just not do that extra credit part, because I have too much going on in other classes and decided to just do the 6x10. It would take a lot more coding to keep track of the size..
Came up with just using this:
void ReadChart(string seatChart[10][6], int RowNum[10]) {
ifstream inChart;
inChart.open("chartIn.txt");
for (int i = 0; i < 10; i++) {
inChart >> RowNum[i];
for (int j = 0; j < 6; j++) {
if (inChart.eof()) {
break;
}
inChart >> seatChart[i][j];
}
}
}
However, I do have another problem if you'd like to help?
In order to reserve the seat, we have to obtain the seat that the user decides (EX: 2A, 3D). We have to obtain that with a string, but this is what I have done. I obtained the input separately with an int and a char, but he wants to obtain it as a string and after obtaining it as a string, we can play around with it however we want, just as long as we initially obtain it as a string. Is there anyway for me to obtain it with a string and take that string and return back to what I have here so I do not have to change anything? Also, all the if statements are a work in progress still.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
void ReserveSeat(string seatChart[10][6], int RowNum[10]) {
int RowChoice;
char SectionChoice;
string SeatChoice;
do {
cout << "Please choose a seat to reserve, with the row number and section seat (Ex: 3A, 2D): " << endl;
cin >> RowChoice >> SectionChoice;
if (islower(SectionChoice)) {
SectionChoice = toupper(SectionChoice);
}
else if (RowChoice < 1 || RowChoice > 10 || SectionChoice < 'A' || SectionChoice > 'F') {
cout << "Not a valid option, please try again. " << endl;
}
else {
SectionChoice = SectionChoice;
}
SectionChoice = SectionChoice - 'A';
if (seatChart[RowChoice - 1][SectionChoice] == "X") {
cout << "Sorry, this seat is already reserved please try another reservation " << endl;
}
else {
seatChart[RowChoice - 1][SectionChoice] = 'X';
cout << "Seat was successfully reserved" << endl;
}
} while (seatChart[RowChoice - 1][SectionChoice] != "X");
}
| |