From 8cf1283a4ffb9fe1901c29c087fa376de82726af Mon Sep 17 00:00:00 2001 From: angeld55 Date: Sat, 19 Feb 2022 23:30:52 +0200 Subject: clean up --- Sem. 13/Figures/Shape.cpp | 52 ----------------------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 Sem. 13/Figures/Shape.cpp (limited to 'Sem. 13/Figures/Shape.cpp') diff --git a/Sem. 13/Figures/Shape.cpp b/Sem. 13/Figures/Shape.cpp deleted file mode 100644 index 27bb9e9..0000000 --- a/Sem. 13/Figures/Shape.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "Shape.h" - -Shape::Shape(size_t pointsCount) : pointsCount(pointsCount) -{ - points = new point[pointsCount]; // [0,0], [0,0].... -} - -void Shape::copyFrom(const Shape& other) -{ - points = new point[other.pointsCount]; - - for (int i = 0; i < other.pointsCount; i++) - points[i] = other.points[i]; -} -void Shape::free() -{ - delete[] points; -} - -Shape::Shape(const Shape& other) -{ - copyFrom(other); -} -Shape& Shape::operator= (const Shape& other) -{ - if (this != &other) - { - free(); - copyFrom(other); - } - return *this; -} -Shape::~Shape() -{ - free(); -} - -const Shape::point& Shape::getPointAtIndex(size_t index) const -{ - if (index >= pointsCount) - throw std::exception("Invalid point index!"); - - return points[index]; -} - -void Shape::setPoint(size_t pointIndex, int x, int y) -{ - if (pointIndex >= pointsCount) - throw std::exception("Invalid point index!"); - - points[pointIndex] = point(x, y); -} -- cgit v1.3.1-23-gd82d