myCircle.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "myCircle.h"
  2. void Circle::WhereAmI()
  3. {
  4. std::cout << "Now I am in class Circle" << std::endl;
  5. }
  6. void Circle::WhereAmIVirtual()
  7. {
  8. std::cout << "Now I am in class Circle" << std::endl;
  9. }
  10. Circle::Circle(double x, double y, double radius, colour colour, bool contour, double transparency)
  11. :Shape(colour, contour, transparency)//ïåðåäà÷à ïàðàìåòðîâ êîíñòðóêòîðó áàçîâîãî êëàññà
  12. {
  13. m_x = x;
  14. m_y = y;
  15. m_radius = radius;
  16. }
  17. Circle::Circle(const Circle& other)
  18. :Shape(other)//óràçàíèå êàêèì êîíñòðóêòîðîì áàçîâîãî êëàññà èíèöèàëèçèðîâàòü áàçóâóþ ÷àñòü
  19. {
  20. m_x = other.m_x;
  21. m_y = other.m_y;
  22. m_radius = other.m_radius;
  23. }
  24. Circle::Circle(const Rect& rect)
  25. :Shape(rect)//óràçàíèå êàêèì êîíñòðóêòîðîì áàçîâîãî êëàññà èíèöèàëèçèðîâàòü áàçóâóþ ÷àñòü
  26. {
  27. int tmp_left, tmp_right, tmp_top, tmp_bottom;
  28. rect.GetAll(tmp_left, tmp_right, tmp_top, tmp_bottom);
  29. m_x = (tmp_right + tmp_left)/2;
  30. m_y = (tmp_bottom + tmp_top)/2;
  31. if ((tmp_right - tmp_left) < (tmp_bottom - tmp_top))
  32. {
  33. m_radius = (tmp_right - tmp_left) / 2;
  34. }
  35. else { m_radius = (tmp_bottom - tmp_top) / 2; }
  36. }
  37. void Circle::Inflate(int inflate)
  38. {
  39. m_radius += inflate / 2;
  40. }
  41. Circle::~Circle()
  42. {
  43. std::cout << "Now I am in Circle's destructor!" << std::endl;
  44. }