Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3.  
  4. using namespace std;
  5.  
  6. class Money
  7. {
  8. private:
  9.     int nominal;
  10.     int amount;
  11.     static int count;
  12. public:
  13.     Money() : nominal(0), amount(0)
  14.     {
  15.         count++;
  16.     };
  17.  
  18.     Money(int n, int a) : nominal(n), amount(a)
  19.     {
  20.         count++;
  21.     };
  22.  
  23.     void show_on_screen()
  24.     {
  25.         cout << "У вас есть " << amount << " купюр номиналом " << nominal << "руб. на вашем счету" << endl;
  26.         cout << "Итого: " << get_money() << "руб." << endl;
  27.     }
  28.  
  29.     bool check_price(double price)
  30.     {
  31.         if ( (double)get_money() / price >= 1.0)
  32.             return true;
  33.         else
  34.             return false;
  35.     }
  36.    
  37.     unsigned int buy_product(int price)
  38.     {
  39.         return (get_money() / price);
  40.     }
  41.  
  42.     void set_money(int n, int a)
  43.     {
  44.         this->nominal = n;
  45.         this->amount = a;
  46.     }
  47.  
  48.     int get_money()
  49.     {
  50.         return (nominal * amount);
  51.     }
  52.  
  53.     int get_count()
  54.     {
  55.         return count;
  56.     }
  57.  
  58.     Money operator++()
  59.     {
  60.         return Money(nominal, amount++);
  61.     }
  62.     Money operator--()
  63.     {
  64.         return Money(nominal, amount--);
  65.     }
  66.     Money operator+(int a)
  67.     {
  68.         return Money(nominal, amount + a);
  69.     }
  70. };
  71.  
  72. int Money::count = 0;
  73.  
  74. int main()
  75. {
  76.     SetConsoleCP(1251);
  77.     SetConsoleOutputCP(1251);
  78.  
  79.     Money x(10, 50);
  80.     x.show_on_screen();
  81.  
  82.     system("pause");
  83.     return 0;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement