#include <iostream>
using namespace std;
class Bus
{
public:
Bus() {};
void move_bus(int n =1)
{
cout << "Bus stop " << n << endl;
if (n == count_stop)
{
cout << "The bus has completed its journey" << endl;
return;
}
for (int i = 0;i < places; i++)
{
if (passenger[i] <= n)
{
passenger[i] = 0;
}
}
cout << "Passengers got off the bus" << endl;
char choise;
int pay;
cout << "Passengers boarding in progress: " << endl;
for (int i = 0; i < places; i++)
{
if (passenger[i] == 0)
{
cout << "Are there passengers for boarding? (y/n) ";
cin >> choise;
if (choise != 'y')
{
break;
}
cout << "What stop does the passenger take ? ";
cin >> passenger[i];
cout << "Pay the fare: ";
cin >> pay;
payments += pay;
}
}
cout << "Passenger boarding completed" << endl;
move_bus(n + 1);
}
float payments{ 0 };
int count_stop{ 7 };
static const int places = 60;
int passenger[places] = {};
private:
};
int main()
{
// example of program execution
Bus bus_example;
bus_example.move_bus();
cout << "Total revenues: "<<bus_example.payments;
return 0;
}
Comments
Leave a comment