Guys, please help me with this. I don't know what to do.
Problem: Seat Reservation System
You are tasked to create a C++ program that will facilitate a seat reservation system for an Airplane Company with 26-seater aircrafts. The
seats are initialiazed using the letters of the alphabet making 26 seats available for passengers. Additional 2 seats at the first row in the right
wing are reserved for flight attendants. Thus, the entire aircraft passenger area consist of 7 rows with 4 columns. The program should continue to accept passengers until the plane is fully booked. Denote occupied seats with the asterisk(*) symbol and prompt a notification message each time the user tries to reserve a seat that has already been occupied. The program repeats until the user
types a period(.) to exit.
#include <iostream>
using namespace std;
void dispArrayValues(char Seat[][4],const int r, const int c);
void askReservation(char Seat[][4],const int r, const int c);
void Status(char Seat[][4],const int r, const int c);
void Space(char Seat[][4], const int c);
void dispArrayValues(char Seat[][4],const int r, const int c);
void askReservation(char Seat[][4],const int r, const int c);
void Status(char Seat[][4],const int r, const int c);
void Space(char Seat[][4], const int c);
void dispArrayValues(char Seat[][4],const int r, const int c);
void askReservation(char Seat[][4],const int r, const int c);
void Status(char Seat[][4],const int r, const int c);
void Space(char Seat[][4], const int c);
std::string seems like overkill for a simple seat array. char seems like it would be simpler.
lines 12-17: You're going to have problems comparing the first seat in each row because you've included the \n character in the string literal.
I agree with Thomas1965 that you should use a 7x4 array. Leave the center isle to your formatting procedure. It does not represent a seat.
I also agree that the [] do not belong as part of the user input or the seat array. You're just making the program user unfriendly. It's easy enough to format the [] when you display the seat array.
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
Even using multiple dimensions seems like overkill. I would leave the concept of rows to the formatting procedure as well.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void printSeats(const std::vector<char>& seats)
{
for(int i = 0; i < seats.size(); ++i)
{
if( i % 4 == 0) //after every 4 seats, put a line break for a new row
{
std::cout << '\n';
}
elseif(i % 2 == 0) //pair the seats up by printing an aisle in the middle
{
std::cout << " ";
}
std::cout << seats.at(i) << ' ';
}
}