Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- class Currency
- {
- double size;
- int code;
- double toDoll;
- public:
- Currency()
- :size(0), code(0), toDoll(1)
- { }
- Currency(double size)
- {
- this->size = size;
- code = 0;
- toDoll = 0;
- }
- Currency(double size, int code, double toDoll)
- {
- this->size = size;
- this->code = code;
- this->toDoll = toDoll;
- }
- double getSize()
- {
- return size;
- }
- int getCode()
- {
- return code;
- }
- double getToDoll()
- {
- return toDoll;
- }
- void setSize(double size)
- {
- this->size = size;
- }
- void setCode(int code)
- {
- this->code = code;
- }
- void setToDoll(double toDoll)
- {
- this->toDoll = toDoll;
- }
- void curInfo()
- {
- cout << "size = " << size << endl << "code = " << code << endl << "Currency to dollar = " << toDoll<<endl;
- }
- void macth(const Currency& other)
- {
- if (size*toDoll == other.size*other.toDoll) cout << code << " equal to " << other.code<<endl;
- else if (size*toDoll < other.size*other.toDoll) cout << code << " smaller than " << other.code<<endl;
- else cout << code << " bigger than " << other.code<<endl;
- }
- double inDoll()
- {
- return size*toDoll;
- }
- double operator + (Currency& other)
- {
- return inDoll() + other.inDoll();
- }
- };
- int main()
- {
- Currency cur1;
- Currency cur2(1000);
- Currency cur3(500,15,1.03);
- Currency cur4(200,3,0.05);
- double temp = cur3 + cur4;
- cur3.curInfo();
- cur4.macth(cur3);
- cur1.setCode(4);
- cur3.setSize(20);
- cur4.curInfo();
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement