Website Summary Files Commits Branches @commit @diff @stats
path: root / Polymorphism / Shapes / ShapeCollection.cpp
diff options
context:
space:
mode:
Commit0218c678e13e1cb94a352c91733cea68467dc566 (patch)
Author
 Angeld55 <angel_dimitriev@abv.bg>
2021-02-14 23:06:35 +0200
Committer
 Angeld55 <angel_dimitriev@abv.bg>
2021-02-14 23:06:35 +0200
Files16fb3114cb560242458d10411765e50f5d6183db /Polymorphism/Shapes/ShapeCollection.cpp
Object-oriented_programming_FMI-0218c678e13e1cb94a352c91733cea68467dc566.tar
Object-oriented_programming_FMI-0218c678e13e1cb94a352c91733cea68467dc566.tar.gz
Object-oriented_programming_FMI-0218c678e13e1cb94a352c91733cea68467dc566.zip
Parentd4ae0ef9ec1b54420176c4a88e09f2fd44ae31b0 (diff)
start from scratch
1 files changed, 0 insertions, 88 deletions
-rw-r--r--Polymorphism/Shapes/ShapeCollection.cpp88
diff --git a/Polymorphism/Shapes/ShapeCollection.cpp b/Polymorphism/Shapes/ShapeCollection.cpp
deleted file mode 100644
index 8fcad3c..0000000
--- a/Polymorphism/Shapes/ShapeCollection.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-#include "ShapeCollection.h"
-
-ShapeCollection::ShapeCollection()
-{
- count = 0;
- capacity = 8;
-
- data = new Shape*[capacity];
-}
-
-void ShapeCollection::AddCircle(int x1, int y1, int r)
-{
- Circle* current = new Circle(x1, y1, r);
- Add(current);
-
-}
-void ShapeCollection::AddTriagnle(int x1, int y1, int x2, int y2, int x3, int y3)
-{
- Triangle* current = new Triangle(x1, y1, x2, y2, x3, y3);
- Add(current);
-}
-void ShapeCollection::AddRect(int x1, int y1, int x2, int y2)
-{
- Rectangle* current = new Rectangle(x1, y1, x2, y2);
- Add(current);
-}
-void ShapeCollection::Add(Shape* currentShape)
-{
- if (count == capacity)
- Resize();
- data[count++] = currentShape;
-}
-void ShapeCollection::Free()
-{
- for (int i = 0; i < count; i++)
- delete data[i];
-
- delete[] data;
-}
-void ShapeCollection::CopyFrom(const ShapeCollection& other)
-{
- data = new Shape*[other.count];
- capacity = other.capacity;
- count = other.count;
- for (int i = 0; i < other.count; i++)
- data[i] = other.data[i]->clone();
-
-}
-ShapeCollection::ShapeCollection(const ShapeCollection& other)
-{
- CopyFrom(other);
-}
-ShapeCollection& ShapeCollection::operator = (const ShapeCollection& other)
-{
- if (this != &other)
- {
- Free();
- CopyFrom(other);
- }
- return *this;
-}
-ShapeCollection::~ShapeCollection()
-{
- Free();
-}
-void ShapeCollection::Resize()
-{
- Shape** temp = new Shape*[capacity * 2];
- capacity *= 2;
- for (int i = 0; i < count; i++)
- temp[i] = data[i];
- delete[] data;
- data = temp;
-
-
-}
-void ShapeCollection::PrintAllAreas()
-{
- for (int i = 0; i < count; i++)
- std::cout << data[i]->getArea() << " ";
- std::cout<<std::endl;
-}
-void ShapeCollection::PrintAllPers()
-{
- for (int i = 0; i < count; i++)
- std::cout << data[i]->getPer() << " ";
- std::cout << std::endl;
-} \ No newline at end of file