test.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <math.h>
  4. using namespace std;
  5. class Date
  6. {
  7. public:
  8. Date() : day(1), month(1), year(2000) {}
  9. Date(int d, int m, int y) : day(d), month(m), year(y) {}
  10. ~Date() {}
  11. private:
  12. int day;
  13. int month;
  14. int year;
  15. public:
  16. int getDay() {
  17. return day;
  18. }
  19. void print()
  20. {
  21. cout << day << "." << month << "." << year << endl;
  22. }
  23. };
  24. //
  25. class Power
  26. {
  27. public:
  28. Power() {}
  29. Power(double val_one, double val_two) : a(val_one), b(val_two) {}
  30. private:
  31. double a;
  32. double b;
  33. public:
  34. void set(double val_one, double val_two)
  35. {
  36. a = val_one;
  37. b = val_two;
  38. }
  39. double calculate()
  40. {
  41. return pow(a, b);
  42. }
  43. };
  44. //
  45. class RGB
  46. {
  47. public:
  48. RGB() : red(0), green(0), blue(0) {}
  49. RGB(unsigned char r, unsigned char g, unsigned char b) : red(r), green(g), blue(b) {}
  50. private:
  51. unsigned char red;
  52. unsigned char green;
  53. unsigned char blue;
  54. public:
  55. void print() {
  56. cout << "(" << (int)red << "," << (int)green << "," << (int)blue << ")" << endl;
  57. }
  58. void invert() {
  59. red = 255 - red;
  60. green = 255 - green;
  61. blue = 255 - blue;
  62. }
  63. };
  64. int main() {
  65. // Date today(6, 9, 2023);
  66. // today.print();
  67. // Date birthday;
  68. // birthday.print();
  69. // Power p(2, 2);
  70. // cout << p.calculate() << endl;
  71. RGB rgb(12, 54, 231);
  72. rgb.print();
  73. rgb.invert();
  74. rgb.print();
  75. return 0;
  76. }