Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <exception>
- using namespace std;
- ifstream in("input.txt");
- ofstream out("output.txt");
- class Money {
- int nominal;
- int amount;
- public:
- void print()
- {
- out << "nominal : " << nominal << " amount : " << amount << endl;
- }
- bool isEnough(int x)
- {
- return nominal * amount >= x;
- }
- int countProductWithCost(int y)
- {
- return nominal * amount / y;
- }
- void setNominal(int nominal)
- {
- this->nominal = nominal;
- }
- void setAmount(int amount)
- {
- this->amount = amount;
- }
- long long overall()
- {
- return amount * 1LL * nominal;// 1LL - приведение к типу long long
- }
- //префексная форма ++a
- Money operator++()
- {
- this->amount++;
- return *this;
- }
- Money operator--()
- {
- this->amount--;
- return *this;
- }
- // постфиксная форма a++
- Money operator++(int)
- {
- Money b;
- b.setAmount(this->amount);
- b.setNominal(this->nominal);
- this->amount++;
- return b;
- }
- Money operator--(int)
- {
- Money b;
- b.setAmount(this->amount);
- b.setNominal(this->nominal);
- this->amount--;
- return b;
- }
- Money operator + (int k)
- {
- this->amount += k;
- return *this;
- }
- };
- void Print(Money a)
- {
- a.print();
- }
- int main()
- {
- Money a;
- a.setAmount(10);
- a.setNominal(10);
- a.print();
- out << "overall: " << a.overall() << endl;
- a = a + 10;
- a.print();
- out << "count Product With Cost 12 : " << a.countProductWithCost(12);
- }
Add Comment
Please, Sign In to add comment