Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <Windows.h>
- using namespace std;
- class Money
- {
- private:
- int nominal;
- int amount;
- static int count;
- public:
- Money() : nominal(0), amount(0)
- {
- count++;
- };
- Money(int n, int a) : nominal(n), amount(a)
- {
- count++;
- };
- void show_on_screen()
- {
- cout << "У вас есть " << amount << " купюр номиналом " << nominal << "руб. на вашем счету" << endl;
- cout << "Итого: " << get_money() << "руб." << endl;
- }
- bool check_price(double price)
- {
- if ( (double)get_money() / price >= 1.0)
- return true;
- else
- return false;
- }
- unsigned int buy_product(int price)
- {
- return (get_money() / price);
- }
- void set_money(int n, int a)
- {
- this->nominal = n;
- this->amount = a;
- }
- int get_money()
- {
- return (nominal * amount);
- }
- int get_count()
- {
- return count;
- }
- Money operator++()
- {
- return Money(nominal, amount++);
- }
- Money operator--()
- {
- return Money(nominal, amount--);
- }
- Money operator+(int a)
- {
- return Money(nominal, amount + a);
- }
- };
- int Money::count = 0;
- int main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- Money x(10, 50);
- x.show_on_screen();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement