View difference between Paste ID: UNSHeLjB and RVByebk9
SHOW: | | - or go back to the newest paste.
1
#include <iostream>
2
#include <string>
3
4
using namespace std;
5
6
void menu();
7
void addBooking();
8
void printArray();
9
10
char seatArray[13][4]  {{'*', '*', '*', '*'},
11
                        {'*', '*', '*', '*'},
12
                        {'*', '*', '*', '*'},
13
                        {'*', '*', '*', '*'},
14
                        {'*', '*', '*', '*'},
15
                        {'*', '*', '*', '*'},
16
                        {'*', '*', '*', '*'},
17
                        {'*', '*', '*', '*'},
18
                        {'*', '*', '*', '*'},
19
                        {'*', '*', '*', '*'},
20
                        {'*', '*', '*', '*'},
21
                        {'*', '*', '*', '*'},
22
                        {'*', '*', '*', '*'}
23
                    };
24
25
char occupied = 'X';
26
27
void menu()
28
{
29
    int userDecision = 0;
30
31
    cout << endl;
32
    cout << "Welcome to SpeakoN Airlines" << endl;
33
34
    cout << "[1] Create Booking\n[2] View Seats" << endl;
35
36
    cin >> userDecision;
37
38
    switch(userDecision)
39
    {
40
41
    case 1:
42
        addBooking();
43
        break;
44
45
    case 2:
46
        printArray();
47
        menu();
48
        break;
49
    }
50
}
51
52
void addBooking()
53
{
54
    int type, seat;
55
56
57
    cout << "Ticket Type:\n[1]First Class\n[2]Business\n[3]Economy\n" << endl;
58
    cin >> type;
59
60
    switch (type)
61
    {
62
63
    case 1:
64
65
        cout << "You Chose: First Class\n" << endl;
66
67
        cout << "Ticket Type:\n[1]Seat 1\n[2]Seat 2\n[3]Seat 3\n[4]Seat 4\n" << endl;
68
        cin >> seat;
69
70
        for(int rows = 0; rows < 2; rows++)
71
        {
72
73
            if(seatArray[rows][seat - 1] != occupied)
74
            {
75
                cout << "Row: " << rows + 1 << " | Seat " << seat << " is Available! Booking Confirmed For: ";
76
                seatArray[rows][seat - 1] = occupied;
77
78
                cout << "Row: " << rows + 1 << " | Seat: " << seat << endl;
79
80
                break;
81
82
            }
83
            else if(seatArray[rows][seat - 1] == occupied && rows <= 2)
84
            {
85
                cout << "Row: " << rows + 1 << " | Seat: " << seat << " is Unavailable!" << endl;
86
            }
87
88
        }
89
        menu();
90
        break;
91
92
    case 2:
93
        cout << "You Chose: Business Class\n" << endl;
94
95
        cout << "Ticket Type:\n[1]Seat 1\n[2]Seat 2\n[3]Seat 3\n[4]Seat 4\n" << endl;
96
        cin >> seat;
97
98
        for(int rows = 2; rows < 6; rows++)
99
        {
100
            if(seatArray[rows][seat - 1] != occupied)
101
            {
102
                cout << "Row: " << rows + 1 << " | Seat " << seat << " is Available! Booking Confirmed For: ";
103
                seatArray[rows][seat - 1] = occupied;
104
105
                cout << "Row: " << rows + 1 << " Seat: " << seat << endl;
106
107
                break;
108
            }
109
            else if(seatArray[rows][seat - 1] == occupied && rows <= 6)
110
            {
111
                cout << "Row: " << rows + 1 << " | Seat: " << seat << " is Unavailable!" << endl;
112
113
            }
114
115
        }
116
        menu();
117
        break;
118
119
120
    case 3:
121
        cout << "You Chose: Economy Class\n" << endl;
122
123
        cout << "Ticket Type:\n[1]Seat 1\n[2]Seat 2\n[3]Seat 3\n[4]Seat 4\n" << endl;
124
        cin >> seat;
125
126
        for(int rows = 6; rows < 13; rows++)
127
        {
128
            if(seatArray[rows][seat - 1] != occupied)
129
            {
130
131
                cout << "Row: " << rows + 1 << " | Seat " << seat << " is Available! Booking Confirmed For: ";
132
                seatArray[rows][seat - 1] = 'occupied;
133
134
                cout << "Row: " << rows + 1 << " Seat: " << seat << endl;
135
136
                break;
137
            }
138
            else if(seatArray[rows][seat - 1] == occupied && rows <= 13)
139
            {
140
                cout << "Row: " << rows + 1 << " | Seat: " << seat << " is Unavailable!" << endl;
141
            }
142
143
        }
144
145
        menu();
146
        break;
147
    }
148
}
149
150
void printArray()
151
{
152
    cout << endl;
153
154
    for(int rows = 0; rows < 13; rows++)
155
    {
156
157
        for(int cols = 0; cols < 4; cols++)
158
        {
159
160
            cout << seatArray[rows][cols] << "\t";
161
162
        }
163
        cout << endl;
164
    }
165
166
}
167
168
int main()
169
{
170
    menu();
171
}