Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- void menu();
- void addBooking();
- void printArray();
- char seatArray[13][4] {{'*', '*', '*', '*'},
- {'*', '*', '*', '*'},
- {'*', '*', '*', '*'},
- {'*', '*', '*', '*'},
- {'*', '*', '*', '*'},
- {'*', '*', '*', '*'},
- {'*', '*', '*', '*'},
- {'*', '*', '*', '*'},
- {'*', '*', '*', '*'},
- {'*', '*', '*', '*'},
- {'*', '*', '*', '*'},
- {'*', '*', '*', '*'},
- {'*', '*', '*', '*'}
- };
- char occupied = 'X';
- void menu()
- {
- int userDecision = 0;
- cout << endl;
- cout << "Welcome to SpeakoN Airlines" << endl;
- cout << "[1] Create Booking\n[2] View Seats" << endl;
- cin >> userDecision;
- switch(userDecision)
- {
- case 1:
- addBooking();
- break;
- case 2:
- printArray();
- menu();
- break;
- }
- }
- void addBooking()
- {
- int type, seat;
- cout << "Ticket Type:\n[1]First Class\n[2]Business\n[3]Economy\n" << endl;
- cin >> type;
- switch (type)
- {
- case 1:
- cout << "You Chose: First Class\n" << endl;
- cout << "Ticket Type:\n[1]Seat 1\n[2]Seat 2\n[3]Seat 3\n[4]Seat 4\n" << endl;
- cin >> seat;
- for(int rows = 0; rows < 2; rows++)
- {
- if(seatArray[rows][seat - 1] != occupied)
- {
- cout << "Row: " << rows + 1 << " | Seat " << seat << " is Available! Booking Confirmed For: ";
- seatArray[rows][seat - 1] = occupied;
- cout << "Row: " << rows + 1 << " | Seat: " << seat << endl;
- break;
- }
- else if(seatArray[rows][seat - 1] == occupied && rows <= 2)
- {
- cout << "Row: " << rows + 1 << " | Seat: " << seat << " is Unavailable!" << endl;
- }
- }
- menu();
- break;
- case 2:
- cout << "You Chose: Business Class\n" << endl;
- cout << "Ticket Type:\n[1]Seat 1\n[2]Seat 2\n[3]Seat 3\n[4]Seat 4\n" << endl;
- cin >> seat;
- for(int rows = 2; rows < 6; rows++)
- {
- if(seatArray[rows][seat - 1] != occupied)
- {
- cout << "Row: " << rows + 1 << " | Seat " << seat << " is Available! Booking Confirmed For: ";
- seatArray[rows][seat - 1] = occupied;
- cout << "Row: " << rows + 1 << " Seat: " << seat << endl;
- break;
- }
- else if(seatArray[rows][seat - 1] == occupied && rows <= 6)
- {
- cout << "Row: " << rows + 1 << " | Seat: " << seat << " is Unavailable!" << endl;
- }
- }
- menu();
- break;
- case 3:
- cout << "You Chose: Economy Class\n" << endl;
- cout << "Ticket Type:\n[1]Seat 1\n[2]Seat 2\n[3]Seat 3\n[4]Seat 4\n" << endl;
- cin >> seat;
- for(int rows = 6; rows < 13; rows++)
- {
- if(seatArray[rows][seat - 1] != occupied)
- {
- cout << "Row: " << rows + 1 << " | Seat " << seat << " is Available! Booking Confirmed For: ";
- seatArray[rows][seat - 1] = occupied;
- cout << "Row: " << rows + 1 << " Seat: " << seat << endl;
- break;
- }
- else if(seatArray[rows][seat - 1] == occupied && rows <= 13)
- {
- cout << "Row: " << rows + 1 << " | Seat: " << seat << " is Unavailable!" << endl;
- }
- }
- menu();
- break;
- }
- }
- void printArray()
- {
- cout << endl;
- for(int rows = 0; rows < 13; rows++)
- {
- for(int cols = 0; cols < 4; cols++)
- {
- cout << seatArray[rows][cols] << "\t";
- }
- cout << endl;
- }
- }
- int main()
- {
- menu();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement