Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Currency
  6. {
  7. double size;
  8. int code;
  9. double toDoll;
  10. public:
  11. Currency()
  12. :size(0), code(0), toDoll(1)
  13. { }
  14. Currency(double size)
  15. {
  16. this->size = size;
  17. code = 0;
  18. toDoll = 0;
  19. }
  20. Currency(double size, int code, double toDoll)
  21. {
  22. this->size = size;
  23. this->code = code;
  24. this->toDoll = toDoll;
  25. }
  26.  
  27. double getSize()
  28. {
  29. return size;
  30. }
  31. int getCode()
  32. {
  33. return code;
  34. }
  35. double getToDoll()
  36. {
  37. return toDoll;
  38. }
  39.  
  40. void setSize(double size)
  41. {
  42. this->size = size;
  43. }
  44. void setCode(int code)
  45. {
  46. this->code = code;
  47. }
  48. void setToDoll(double toDoll)
  49. {
  50. this->toDoll = toDoll;
  51. }
  52.  
  53. void curInfo()
  54. {
  55. cout << "size = " << size << endl << "code = " << code << endl << "Currency to dollar = " << toDoll<<endl;
  56. }
  57.  
  58. void macth(const Currency& other)
  59. {
  60. if (size*toDoll == other.size*other.toDoll) cout << code << " equal to " << other.code<<endl;
  61. else if (size*toDoll < other.size*other.toDoll) cout << code << " smaller than " << other.code<<endl;
  62. else cout << code << " bigger than " << other.code<<endl;
  63. }
  64.  
  65. double inDoll()
  66. {
  67. return size*toDoll;
  68. }
  69.  
  70. double operator + (Currency& other)
  71. {
  72. return inDoll() + other.inDoll();
  73. }
  74.  
  75. };
  76.  
  77. int main()
  78. {
  79. Currency cur1;
  80. Currency cur2(1000);
  81. Currency cur3(500,15,1.03);
  82. Currency cur4(200,3,0.05);
  83. double temp = cur3 + cur4;
  84. cur3.curInfo();
  85. cur4.macth(cur3);
  86. cur1.setCode(4);
  87. cur3.setSize(20);
  88. cur4.curInfo();
  89. system("pause");
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement