Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- using namespace std;
- class Kasa
- {
- private:
- unsigned int autoCount;
- double cost;
- public:
- Kasa()
- {
- autoCount = 0;
- cost = 0;
- }
- void payingCar()
- {
- autoCount++;
- cost += 0.50;
- }
- void nopayCar()
- {
- autoCount++;
- }
- void display()
- {
- cout << "Auto count: " << autoCount << endl;
- cout << "Cost: " << cost << endl;
- }
- };
- int menu()
- {
- cout << "1. Add paying car" << endl;
- cout << "2. Add nopay car" << endl;
- int result = getch();
- return result;
- }
- int main()
- {
- Kasa kasa;
- int answer;
- while ((answer = menu()) != 27)
- {
- switch (answer)
- {
- case 49:
- kasa.payingCar();
- cout << "Add paying car!" << endl;
- break;
- case 50:
- kasa.nopayCar();
- cout << "Add nopay car!" << endl;
- break;
- default:
- cout << "Error answer!" << endl;
- break;
- }
- }
- kasa.display();
- getchar();
- return 0;
- }
Add Comment
Please, Sign In to add comment