Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 13 / Farm / Farm.cpp
diff options
context:
space:
mode:
Commite012bcac0a5c5fc804fbeadb0e8ab382c5e6feb7 (patch)
Author
 angeld55 <angel_dimitriev@abv.bg>
2022-05-31 00:56:24 +0300
Committer
 angeld55 <angel_dimitriev@abv.bg>
2022-05-31 00:56:24 +0300
Files5e0fa501c9dae5a2ab8f3b043d1d43946ed66b44 /Sem. 13/Farm/Farm.cpp
Object-oriented_programming_FMI-e012bcac0a5c5fc804fbeadb0e8ab382c5e6feb7.tar
Object-oriented_programming_FMI-e012bcac0a5c5fc804fbeadb0e8ab382c5e6feb7.tar.gz
Object-oriented_programming_FMI-e012bcac0a5c5fc804fbeadb0e8ab382c5e6feb7.zip
Parentb5eb0ed6a0a3f8e728c30e5b03d2b366881aca76 (diff)
split in to folders
1 files changed, 0 insertions, 63 deletions
-rw-r--r--Sem. 13/Farm/Farm.cpp63
diff --git a/Sem. 13/Farm/Farm.cpp b/Sem. 13/Farm/Farm.cpp
deleted file mode 100644
index 73cd419..0000000
--- a/Sem. 13/Farm/Farm.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-#include "Farm.h"
-
-void Farm::free()
-{
- for (size_t i = 0; i < animalsCount; i++)
- delete animals[i]; //не се инт. какъв обект е. (вирт дестр)
- delete[] animals;
-}
-void Farm::copyFrom(const Farm& other)
-{
- animals = new Animal * [other.capacity];
- animalsCount = other.animalsCount;
- capacity = other.capacity;
-
- for (size_t i = 0; i < animalsCount; i++)
- {
- animals[i] = other.animals[i]->clone();
- }
-}
-void Farm::resize()
-{
- Animal** newCollection = new Animal * [capacity *= 2];
- for (size_t i = 0; i < animalsCount; i++)
- newCollection[i] = animals[i]; // !!не правим клониране
- delete[] animals;
- animals = newCollection;
-}
-void Farm::addAnimal(const Animal& currentAnimal)
-{
- if (animalsCount == capacity)
- resize();
- animals[animalsCount++] = currentAnimal.clone();
-}
-
-Farm::Farm()
-{
- capacity = 8;
- animalsCount = 0;
- animals = new Animal * [capacity];
-}
-Farm::Farm(const Farm& other)
-{
- copyFrom(other);
-}
-Farm& Farm::operator=(const Farm& other)
-{
- if (this != &other)
- {
- free();
- copyFrom(other);
- }
- return *this;
-}
-Farm::~Farm()
-{
- free();
-}
-
-void Farm::allSayHello() const
-{
- for (size_t i = 0; i < animalsCount; i++)
- animals[i]->sayHello();
-}