1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #include "myCircle.h"
- void Circle::WhereAmI()
- {
- std::cout << "Now I am in class Circle" << std::endl;
- }
- void Circle::WhereAmIVirtual()
- {
- std::cout << "Now I am in class Circle" << std::endl;
- }
- Circle::Circle(double x, double y, double radius, colour colour, bool contour, double transparency)
- :Shape(colour, contour, transparency)//ïåðåäà÷à ïàðàìåòðîâ êîíñòðóêòîðó áàçîâîãî êëàññà
- {
- m_x = x;
- m_y = y;
- m_radius = radius;
- }
- Circle::Circle(const Circle& other)
- :Shape(other)//óràçàíèå êàêèì êîíñòðóêòîðîì áàçîâîãî êëàññà èíèöèàëèçèðîâàòü áàçóâóþ ÷àñòü
- {
- m_x = other.m_x;
- m_y = other.m_y;
- m_radius = other.m_radius;
- }
- Circle::Circle(const Rect& rect)
- :Shape(rect)//óràçàíèå êàêèì êîíñòðóêòîðîì áàçîâîãî êëàññà èíèöèàëèçèðîâàòü áàçóâóþ ÷àñòü
- {
- int tmp_left, tmp_right, tmp_top, tmp_bottom;
- rect.GetAll(tmp_left, tmp_right, tmp_top, tmp_bottom);
- m_x = (tmp_right + tmp_left)/2;
- m_y = (tmp_bottom + tmp_top)/2;
-
- if ((tmp_right - tmp_left) < (tmp_bottom - tmp_top))
- {
- m_radius = (tmp_right - tmp_left) / 2;
- }
- else { m_radius = (tmp_bottom - tmp_top) / 2; }
- }
- void Circle::Inflate(int inflate)
- {
- m_radius += inflate / 2;
- }
- Circle::~Circle()
- {
- std::cout << "Now I am in Circle's destructor!" << std::endl;
- }
|