1#include <iostream>
2using namespace std;
3
4
5class Bus
6{
7public:
8 Bus() {};
9
10
11 void move_bus(int n =1)
12 {
13 cout << "Bus stop " << n << endl;
14 if (n == count_stop)
15 {
16 cout << "The bus has completed its journey" << endl;
17 return;
18 }
19 for (int i = 0;i < places; i++)
20 {
21 if (passenger[i] <= n)
22 {
23 passenger[i] = 0;
24 }
25 }
26 cout << "Passengers got off the bus" << endl;
27 char choise;
28 int pay;
29 cout << "Passengers boarding in progress: " << endl;
30 for (int i = 0; i < places; i++)
31 {
32 if (passenger[i] == 0)
33 {
34 cout << "Are there passengers for boarding? (y/n) ";
35 cin >> choise;
36 if (choise != 'y')
37 {
38 break;
39 }
40 cout << "What stop does the passenger take ? ";
41 cin >> passenger[i];
42 cout << "Pay the fare: ";
43 cin >> pay;
44 payments += pay;
45 }
46 }
47 cout << "Passenger boarding completed" << endl;
48 move_bus(n + 1);
49 }
50 float payments{ 0 };
51 int count_stop{ 7 };
52 static const int places = 60;
53 int passenger[places] = {};
54private:
55};
56
57int main()
58{
59 // example of program execution
60 Bus bus_example;
61 bus_example.move_bus();
62 cout << "Total revenues: "<<bus_example.payments;
63 return 0;
64}
65