Website Summary Files Commits Branches @commit @diff @stats
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
Object-oriented_programming_FMI-0218c678e13e1cb94a352c91733cea68467dc566.tar
Object-oriented_programming_FMI-0218c678e13e1cb94a352c91733cea68467dc566.tar.gz
Object-oriented_programming_FMI-0218c678e13e1cb94a352c91733cea68467dc566.zip
Parentd4ae0ef9ec1b54420176c4a88e09f2fd44ae31b0 (diff)
start from scratch
94 files changed, 3 insertions, 3505 deletions
-rw-r--r--Big4_and_composition/Airlines_booking_system/Airline.cpp110
-rw-r--r--Big4_and_composition/Airlines_booking_system/Airline.h28
-rw-r--r--Big4_and_composition/Airlines_booking_system/Airport.cpp56
-rw-r--r--Big4_and_composition/Airlines_booking_system/Airport.h22
-rw-r--r--Big4_and_composition/Airlines_booking_system/Flight.cpp27
-rw-r--r--Big4_and_composition/Airlines_booking_system/Flight.h21
-rw-r--r--Big4_and_composition/Airlines_booking_system/Source.cpp23
-rw-r--r--Big4_and_composition/test1
-rw-r--r--Big4_and_inheritance/Drinks/AlcoholDrink.cpp18
-rw-r--r--Big4_and_inheritance/Drinks/AlcoholDrink.h14
-rw-r--r--Big4_and_inheritance/Drinks/Drink.cpp63
-rw-r--r--Big4_and_inheritance/Drinks/Drink.h21
-rw-r--r--Big4_and_inheritance/Drinks/main.cpp10
-rw-r--r--Big4_and_inheritance/Students/GradesBook.cpp91
-rw-r--r--Big4_and_inheritance/Students/GradesBook.h27
-rw-r--r--Big4_and_inheritance/Students/Student.cpp10
-rw-r--r--Big4_and_inheritance/Students/Student.h15
-rw-r--r--Big4_and_inheritance/Students/User.cpp43
-rw-r--r--Big4_and_inheritance/Students/User.h18
-rw-r--r--Big4_basic_examples/InformaticsStudent/InformaticsStudent.cpp103
-rw-r--r--Big4_basic_examples/InformaticsStudent/InformaticsStudent.h40
-rw-r--r--Big4_basic_examples/README.md1
-rw-r--r--Big4_basic_examples/TestClass/Source.cpp20
-rw-r--r--Big4_basic_examples/TestClass/TestClass.cpp45
-rw-r--r--Big4_basic_examples/TestClass/TestClass.h25
-rw-r--r--Binary_files/BinaryFiles_Cheatsheet.pdfbin61351 -> 0 bytes
-rw-r--r--Binary_files/GetStructsFromBinaryFile.cpp47
-rw-r--r--Binary_files/README.md5
-rw-r--r--Binary_files/SaveAndReadStudents_BinaryFile.cpp47
-rw-r--r--Binary_files/SaveStructsToBinaryFile(as array).cpp37
-rw-r--r--Binary_files/SaveStructsToBinaryFile.cpp40
-rw-r--r--Binary_files/Structs.batbin24 -> 0 bytes
-rw-r--r--Binary_files/StructsBAT (how does it look).pngbin6050 -> 0 bytes
-rw-r--r--Classes/Distance/Distance.cpp105
-rw-r--r--Classes/Distance/Distance.h31
-rw-r--r--Classes/GradesBook(DynamicArray)/GradesBook.cpp91
-rw-r--r--Classes/GradesBook(DynamicArray)/GradesBook.h24
-rw-r--r--Classes/String/String.cpp194
-rw-r--r--Classes/String/String.h45
-rw-r--r--Diamond_problem_and_polymorphism/Chess/Bishop.hpp34
-rw-r--r--Diamond_problem_and_polymorphism/Chess/Board.hpp127
-rw-r--r--Diamond_problem_and_polymorphism/Chess/Figure.hpp35
-rw-r--r--Diamond_problem_and_polymorphism/Chess/Knight.hpp38
-rw-r--r--Diamond_problem_and_polymorphism/Chess/Queen.hpp25
-rw-r--r--Diamond_problem_and_polymorphism/Chess/README.md4
-rw-r--r--Diamond_problem_and_polymorphism/Chess/Rook.hpp31
-rw-r--r--Diamond_problem_and_polymorphism/Chess/main.cpp16
-rw-r--r--Diamond_problem_and_polymorphism/sd1
-rw-r--r--Getters_and_setters_simple_examples/Beer/Beer.cpp43
-rw-r--r--Getters_and_setters_simple_examples/Beer/Beer.h27
-rw-r--r--Getters_and_setters_simple_examples/Beer/main.cpp8
-rw-r--r--Getters_and_setters_simple_examples/Daily_schedule/Event.cpp40
-rw-r--r--Getters_and_setters_simple_examples/Daily_schedule/Event.h19
-rw-r--r--Getters_and_setters_simple_examples/Daily_schedule/Schedule.cpp62
-rw-r--r--Getters_and_setters_simple_examples/Daily_schedule/Schedule.h19
-rw-r--r--Getters_and_setters_simple_examples/Daily_schedule/Source.cpp37
-rw-r--r--Getters_and_setters_simple_examples/Daily_schedule/Time.cpp73
-rw-r--r--Getters_and_setters_simple_examples/Daily_schedule/Time.h21
-rw-r--r--Homework_tasks/Homework_1.pdfbin137954 -> 0 bytes
-rw-r--r--Homework_tasks/Homework_2.pdfbin145320 -> 0 bytes
-rw-r--r--Operator_overloading/Complex/Complex.hpp136
-rw-r--r--Operator_overloading/Vector/Source.cpp14
-rw-r--r--Operator_overloading/Vector/Vector.cpp145
-rw-r--r--Operator_overloading/Vector/Vector.h37
-rw-r--r--Polymorphism/Farm(cloneFunction)/Animal.hpp19
-rw-r--r--Polymorphism/Farm(cloneFunction)/Cat.hpp18
-rw-r--r--Polymorphism/Farm(cloneFunction)/Cow.hpp16
-rw-r--r--Polymorphism/Farm(cloneFunction)/Dog.hpp18
-rw-r--r--Polymorphism/Farm(cloneFunction)/Farm.hpp106
-rw-r--r--Polymorphism/Farm(cloneFunction)/Source.cpp13
-rw-r--r--Polymorphism/MathExpression/Expression.hpp16
-rw-r--r--Polymorphism/MathExpression/Num.hpp26
-rw-r--r--Polymorphism/MathExpression/Operation.hpp48
-rw-r--r--Polymorphism/MathExpression/README.md8
-rw-r--r--Polymorphism/MathExpression/main.hpp43
-rw-r--r--Polymorphism/Shapes/Circle.cpp19
-rw-r--r--Polymorphism/Shapes/Circle.h16
-rw-r--r--Polymorphism/Shapes/Point.h18
-rw-r--r--Polymorphism/Shapes/Rectangle.cpp24
-rw-r--r--Polymorphism/Shapes/Rectangle.h11
-rw-r--r--Polymorphism/Shapes/Shape.cpp50
-rw-r--r--Polymorphism/Shapes/Shape.h27
-rw-r--r--Polymorphism/Shapes/ShapeCollection.cpp88
-rw-r--r--Polymorphism/Shapes/ShapeCollection.h30
-rw-r--r--Polymorphism/Shapes/Source.cpp30
-rw-r--r--Polymorphism/Shapes/Triangle.cpp31
-rw-r--r--Polymorphism/Shapes/Triangle.h12
-rw-r--r--README.md6
-rw-r--r--Smart_pointers/1. uniqe_ptr.cpp56
-rw-r--r--Smart_pointers/2. shared_ptr.cpp53
-rw-r--r--Smart_pointers/3. weak_ptr.cpp52
-rw-r--r--Templates/Queue/Queue.hpp121
-rw-r--r--Templates/Queue/main.cpp23
-rw-r--r--Templates/test.txt0
diff --git a/Big4_and_composition/Airlines_booking_system/Airline.cpp b/Big4_and_composition/Airlines_booking_system/Airline.cpp
deleted file mode 100644
index f5dd3e3..0000000
--- a/Big4_and_composition/Airlines_booking_system/Airline.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-#include "Airline.h"
-
-int Airline::firstFreeIndex()
-{
- for (int i = 0; i < MAXFLIGHTS; i++)
- {
- if (fl[i] == nullptr)
- return i;
- }
- return -1;
-}
-void Airline::CopyFrom(const Airline& other)
-{
- name = new char[strlen(other.name) + 1]; //Копираме именето
- strcpy(name, other.name);
-
- for (int i = 0; i < MAXFLIGHTS; i++)
- {
- if (other.fl[i] == nullptr)
- fl[i] = nullptr;
- else
- {
- fl[i] = new Flight(*other.fl[i]); //извикваме копи контруктора на обектите.
- } // Понеже в other.fl[i] e указател, то трябва да го 'дерефрираме'.
- }
-}
-void Airline::Free() //трябва да изтрием името и всички обекти, към които сочат указателите
-{
- delete[] name;
- for (int i = 0; i < MAXFLIGHTS; i++)
- delete fl[i]; //някои указатели може да имат стойност nullptr, но това няма да доведе до грешка.
-}
-
-
-Airline::Airline(const char* name)
-{
- this->name = new char[strlen(name) + 1];
- strcpy(this->name, name);
-
- for (int i = 0; i < MAXFLIGHTS; i++)
- fl[i] = nullptr;
-}
-
-bool Airline::addFlight(const char* originAirportName, const char* originAirportId,
- const char* destAirportName, const char* destAirportId, int durration)
-{
- int ind = firstFreeIndex();
-
- if (ind == -1) //няма свободни места.
- return false;
-
- fl[ind] = new Flight(originAirportName, originAirportId, destAirportName, destAirportId, durration);
- return true;
-
-}
-bool Airline::addFlight(const Flight& other)
-{
- int ind = firstFreeIndex();
-
- if (ind == -1)//няма свободни места.
- return false;
- fl[ind] = new Flight(other);
- return true;
-}
-Airline::Airline(const Airline& other)
-{
- CopyFrom(other);
-}
-Airline& Airline::operator=(const Airline& other)
-{
- if (this != &other)
- {
- Free();
- CopyFrom(other);
- }
- return *this;
-}
-Airline::~Airline()
-{
- Free();
-}
-bool Airline::containsJourney(const char* originID, const char* destID)
-{
- //TODO -> fix cycles
- if (strcmp(originID, destID))
- return true;
-
- bool solution = false;
-
- for (int i = 0; i < MAXFLIGHTS && !solution; i++)
- {
- if (fl[i] != nullptr)
- {
- if (strcmp(fl[i]->getOrigin().getId(), originID) == 0)
- solution = solution || containsJourney(fl[i]->getDestination().getId(), destID);
- }
- }
- return false;
-}
-void Airline::print()
-{
- for (int i = 0; i < MAXFLIGHTS; i++)
- {
- if (fl[i])
- {
- std::cout << "Flight: ";
- fl[i]->print();
- }
- }
-}
diff --git a/Big4_and_composition/Airlines_booking_system/Airline.h b/Big4_and_composition/Airlines_booking_system/Airline.h
deleted file mode 100644
index 0a8f34c..0000000
--- a/Big4_and_composition/Airlines_booking_system/Airline.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#include "Flight.h"
-
-const int MAXFLIGHTS = 10;
-
-class Airline
-{
- char* name;
- Flight* fl[MAXFLIGHTS]; //масив от указатели към обекти от тип Flight.
-
- int firstFreeIndex();
-
- void CopyFrom(const Airline& other);
- void Free();
-
-public:
- Airline(const char* name);
- Airline(const Airline& other);
- Airline& operator=(const Airline& other);
- ~Airline();
-
- bool addFlight(const char* originAirportName, const char* originAirportId,
- const char* destAirportName, const char* destAirportId, int durration);
- bool addFlight(const Flight& other);
-
- bool containsJourney(const char* origin, const char* dest);
-
- void print();
-};
diff --git a/Big4_and_composition/Airlines_booking_system/Airport.cpp b/Big4_and_composition/Airlines_booking_system/Airport.cpp
deleted file mode 100644
index d9f0c25..0000000
--- a/Big4_and_composition/Airlines_booking_system/Airport.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "Airport.h"
-
-Airport::Airport(const char* cityName,const char* id)
-{
- this->cityName = new char[strlen(cityName) + 1];
- strcpy(this->cityName, cityName);
-
- strcpy(this->id, id);
-}
-
-void Airport::CopyFrom(const Airport& other)
-{
- cityName = new char[strlen(other.cityName) + 1];
- strcpy(cityName, other.cityName);
-
- strcpy(id, other.id); //въпреки че не е динамично заделен, се налага до разпишем ръчно копирането, защото го разписваме за другите член-данни в класа.
-}
-
-void Airport::Free()
-{
- delete[] cityName;
-}
-
-Airport::Airport(const Airport& other)
-{
- CopyFrom(other);
-}
-
-Airport& Airport::operator=(const Airport& other)
-{
- if (this != &other)
- {
- Free();
- CopyFrom(other);
- }
- return *this;
-
-}
-
-Airport::~Airport()
-{
- Free();
-}
-
-const char* Airport::getId() const
-{
- return id;
-}
-const char* Airport::getCityName() const
-{
- return cityName;
-}
-void Airport::print() const
-{
- std::cout << cityName << '(' << id << ')';
-}
diff --git a/Big4_and_composition/Airlines_booking_system/Airport.h b/Big4_and_composition/Airlines_booking_system/Airport.h
deleted file mode 100644
index 98b3547..0000000
--- a/Big4_and_composition/Airlines_booking_system/Airport.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <iostream>
-
-class Airport
-{
-
- char* cityName;
- char id[4];
-
- void CopyFrom(const Airport& other);
- void Free();
-
-public:
-
- Airport(const char* cityName,const char* id);
- Airport(const Airport& other);
- Airport& operator=(const Airport& other);
- ~Airport();
-
- const char* getId() const;
- const char* getCityName() const;
- void print() const;
-}; \ No newline at end of file
diff --git a/Big4_and_composition/Airlines_booking_system/Flight.cpp b/Big4_and_composition/Airlines_booking_system/Flight.cpp
deleted file mode 100644
index b7436a3..0000000
--- a/Big4_and_composition/Airlines_booking_system/Flight.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "Flight.h"
-
-Flight::Flight(const char* originAirportName, const char* originAirportId,
- const char* destAirportName, const char* destAirportId, int durration) : origin(originAirportName, originAirportId), dest(destAirportName,destAirportId)
-{
- this->durration = durration;
-}
-
-Flight::Flight(const Airport& _origin, const Airport& _dest, int durration) : origin(_origin), dest(_dest)
-{
- this->durration = durration;
-}
-const Airport& Flight::getOrigin()
-{
- return origin;
-}
-const Airport& Flight::getDestination()
-{
- return dest;
-}
-void Flight::print() const
-{
- origin.print();
- std::cout << "-->";
- dest.print();
- std::cout << std::endl;
-} \ No newline at end of file
diff --git a/Big4_and_composition/Airlines_booking_system/Flight.h b/Big4_and_composition/Airlines_booking_system/Flight.h
deleted file mode 100644
index 177aeaa..0000000
--- a/Big4_and_composition/Airlines_booking_system/Flight.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "Airport.h"
-
-class Flight
-{
-
-
- Airport origin;
- Airport dest;
- int durration;
-
-public:
- Flight(const char* originAirportName, const char* originAirportId,
- const char* destAirportName, const char* destAirportId, int durration);
-
- Flight(const Airport& origin,const Airport& dest, int durration);
-
- const Airport& getOrigin();
- const Airport& getDestination();
-
- void print() const;
-}; \ No newline at end of file
diff --git a/Big4_and_composition/Airlines_booking_system/Source.cpp b/Big4_and_composition/Airlines_booking_system/Source.cpp
deleted file mode 100644
index 6d84dbd..0000000
--- a/Big4_and_composition/Airlines_booking_system/Source.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-
-#include "Airline.h"
-
-
-
-int main()
-{
-
- Airline a("Lufthansa");
- a.addFlight("Sofia", "SOF", "Berlin", "TGL", 33);
-
- a.addFlight("Berlin", "TGL", "London", "LTN", 55);
-
- a.addFlight("London", "LTN", "Sofia", "SOF", 66);
-
- a.addFlight("Berlin", "SCH", "Sofia", "SOF", 51);
-
- a.addFlight("London", "LTN", "Moscow", "MSC", 96);
-
- a.print();
-
-
-} \ No newline at end of file
diff --git a/Big4_and_composition/test b/Big4_and_composition/test
deleted file mode 100644
index 9daeafb..0000000
--- a/Big4_and_composition/test
+++ /dev/null
@@ -1 +0,0 @@
-test
diff --git a/Big4_and_inheritance/Drinks/AlcoholDrink.cpp b/Big4_and_inheritance/Drinks/AlcoholDrink.cpp
deleted file mode 100644
index 0e20087..0000000
--- a/Big4_and_inheritance/Drinks/AlcoholDrink.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "AlcoholDrink.h"
-
-
-
-AlcoholDrink::AlcoholDrink(const char* mark, int ml, int percentAlcohol) : Drink(mark,ml)
-{
- setAlcohol(percentAlcohol);
-}
-void AlcoholDrink::setAlcohol(int alcohol)
-{
- if (alcohol < 4 || alcohol>98)
- alcohol = 20;
- percentAlcohol = alcohol;
-}
-int AlcoholDrink::getAlcohol() const
-{
- return percentAlcohol;
-}
diff --git a/Big4_and_inheritance/Drinks/AlcoholDrink.h b/Big4_and_inheritance/Drinks/AlcoholDrink.h
deleted file mode 100644
index 0bd1d10..0000000
--- a/Big4_and_inheritance/Drinks/AlcoholDrink.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#pragma once
-
-#include "Drink.h"
-
-class AlcoholDrink : public Drink
-{
-private:
- int percentAlcohol;
-
-public:
- AlcoholDrink(const char* mark, int ml, int percentAlcohol);
- void setAlcohol(int alcohol);
- int AlcoholDrink::getAlcohol() const;
-};
diff --git a/Big4_and_inheritance/Drinks/Drink.cpp b/Big4_and_inheritance/Drinks/Drink.cpp
deleted file mode 100644
index 709446b..0000000
--- a/Big4_and_inheritance/Drinks/Drink.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-#include "Drink.h"
-
-
-void Drink::CopyFrom(const Drink& other)
-{
- int len = strlen(other.mark);
- mark = new char[len + 1];
- strcpy(mark, other.mark);
-
- ml = other.ml;
-}
-void Drink::Free()
-{
- delete[] mark;
- ml = 0;
-}
-
-Drink::Drink()
-{
- mark = new char[6];
- strcpy(mark, "Water");
- ml = 500;
-}
-Drink::Drink(const char* mark, int ml)
-{
- int len = strlen(mark);
- this->mark = new char[len + 1];
- strcpy(this->mark, mark);
-
- setML(ml);
-
-}
-Drink::Drink(const Drink& other)
-{
- CopyFrom(other);
-}
-Drink& Drink::operator=(const Drink& other)
-{
- if (this != &other)
- {
- Free();
- CopyFrom(other);
- }
- return *this;
-}
-Drink::~Drink()
-{
- Free();
-}
-void Drink::setML(int ml)
-{
- if (ml < 100 || ml> 1000)
- ml = 500;
- this->ml = ml;
-}
-int Drink::getML() const
-{
- return ml;
-}
-const char* Drink::getMark() const
-{
- return mark;
-}
diff --git a/Big4_and_inheritance/Drinks/Drink.h b/Big4_and_inheritance/Drinks/Drink.h
deleted file mode 100644
index db93c97..0000000
--- a/Big4_and_inheritance/Drinks/Drink.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#pragma once
-#include <iostream>
-
-class Drink
-{
-private:
- char* mark;
- int ml;
- void CopyFrom(const Drink& other);
- void Free();
-public:
- Drink();
- Drink(const char* mark, int ml);
- Drink(const Drink& other);
- Drink& operator=(const Drink& other);
- ~Drink();
-
- void setML(int ml);
- int getML() const;
- const char* getMark() const;
-};
diff --git a/Big4_and_inheritance/Drinks/main.cpp b/Big4_and_inheritance/Drinks/main.cpp
deleted file mode 100644
index c809123..0000000
--- a/Big4_and_inheritance/Drinks/main.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "AlcoholDrink.h"
-int main()
-{
- AlcoholDrink DR1("Spirt", 100, 98);
-
- AlcoholDrink dr2 (DR1);
- dr2.getMark();
-
-
-}
diff --git a/Big4_and_inheritance/Students/GradesBook.cpp b/Big4_and_inheritance/Students/GradesBook.cpp
deleted file mode 100644
index 6d3de27..0000000
--- a/Big4_and_inheritance/Students/GradesBook.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-#include "GradesBook.h"
-
-
-GradesBook::GradesBook()
-{
- capacity = 4;
- grades = new int[capacity];
- size = 0;
-}
-GradesBook::GradesBook(const GradesBook& other)
-{
- std::cout << "Copy contr of GradesBook" << std::endl;
- CopyFrom(other);
-}
-GradesBook& GradesBook::operator=(const GradesBook& other)
-{
- if (this != &other)
- {
- Free();
- CopyFrom(other);
- }
- return *this;
-}
-GradesBook::~GradesBook()
-{
- Free();
-}
-
-
-void GradesBook::CopyFrom(const GradesBook& other)
-{
- grades = new int[other.capacity];
- for (int i = 0; i < other.size; i++)
- grades[i] = other.grades[i];
- capacity = other.capacity;
- size = other.size;
-}
-void GradesBook::Free()
-{
- delete[] grades;
-}
-
-
-bool GradesBook::isFull()
-{
- return size == capacity;
-}
-void GradesBook::AddGrade(int grade)
-{
- if (!isValidGrade(grade))
- return;
- if (isFull())
- Resize();
- grades[size++] = grade;
-
-}
-void GradesBook::Resize()
-{
- int* temp = new int[capacity * 2];
- for (int i = 0; i < size; i++)
- temp[i] = grades[i];
- capacity *= 2;
- delete[] grades;
- grades = temp;
-}
-void GradesBook::RemoveLastGrade()
-{
- size--;
-}
-bool GradesBook::isValidGrade(int grade)
-{
- return (grade >= 2 && grade <= 6);
-}
-int GradesBook::operator[](int index) const
-{
- if (index < 0 || index >= size)
- return -1;
- return grades[index];
-}
-
-std::ostream& operator<<(std::ostream& stream, GradesBook& obj)
-{
- for (int i = 0; i < obj.capacity; i++)
- {
- if (i < obj.size)
- stream << obj.grades[i] << ' ';
- else
- stream << '_' << ' ';
- }
- return stream;
-} \ No newline at end of file
diff --git a/Big4_and_inheritance/Students/GradesBook.h b/Big4_and_inheritance/Students/GradesBook.h
deleted file mode 100644
index e63e92f..0000000
--- a/Big4_and_inheritance/Students/GradesBook.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#pragma once
-#include <iostream>
-
-class GradesBook
-{
- int* grades;
- int size;
- int capacity;
-
- bool isValidGrade(int grade);
- void Resize();
- void CopyFrom(const GradesBook& other);
- void Free();
-public:
- GradesBook();
- GradesBook(const GradesBook& other);
- GradesBook& operator=(const GradesBook& other);
- ~GradesBook();
-
- bool isFull();
- void AddGrade(int grade);
- void RemoveLastGrade();
-
- int operator[](int index) const;
- friend std::ostream& operator<<(std::ostream& stream, GradesBook& obj);
-
-};
diff --git a/Big4_and_inheritance/Students/Student.cpp b/Big4_and_inheritance/Students/Student.cpp
deleted file mode 100644
index 4734529..0000000
--- a/Big4_and_inheritance/Students/Student.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "Student.h"
-Student::Student(const char* name, int age, int fn): User(name,age)
-{
- this->fn = fn;
-}
-
-void Student::ReceiveGrade(int grade)
-{
- b.AddGrade(grade);
-} \ No newline at end of file
diff --git a/Big4_and_inheritance/Students/Student.h b/Big4_and_inheritance/Students/Student.h
deleted file mode 100644
index aafaf58..0000000
--- a/Big4_and_inheritance/Students/Student.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#pragma once
-#include "User.h"
-#include "GradesBook.h"
-
-class Student : public User
-{
-public:
- int fn;
- GradesBook b;
-
- Student(const char* name, int age, int fn);
- void ReceiveGrade(int grade);
-
-
-};
diff --git a/Big4_and_inheritance/Students/User.cpp b/Big4_and_inheritance/Students/User.cpp
deleted file mode 100644
index 93d34b6..0000000
--- a/Big4_and_inheritance/Students/User.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-#include "User.h"
-
-/*
-User::User(): name(nullptr),age(10)
-{
-
-}
-*/
-
-User::User(const char* name, int age)
-{
- this->name = new char[strlen(name) + 1];
- strcpy(this->name, name);
- this->age = age;
-}
-User::User(const User& other)
-{
- cout << "Copy contr of user" << endl;
- CopyFrom(other);
-}
-User& User::operator=(const User& other)
-{
- if (this != &other)
- {
- Free();
- CopyFrom(other);
- }
- return *this;
-}
-User::~User()
-{
- Free();
-}
-void User::CopyFrom(const User& other)
-{
- name = new char[strlen(other.name) + 1];
- strcpy(name, other.name);
- age = other.age;
-}
-void User::Free()
-{
- delete[] name;
-} \ No newline at end of file
diff --git a/Big4_and_inheritance/Students/User.h b/Big4_and_inheritance/Students/User.h
deleted file mode 100644
index 400057b..0000000
--- a/Big4_and_inheritance/Students/User.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#pragma once
-
-#include <iostream>
-using namespace std;
-class User
-{
-private:
- char* name;
- int age;
- void CopyFrom(const User& other);
- void Free();
-public:
- //User();
- User(const char*name, int age);
- User(const User& other);
- User& operator=(const User& other);
- ~User();
-};
diff --git a/Big4_basic_examples/InformaticsStudent/InformaticsStudent.cpp b/Big4_basic_examples/InformaticsStudent/InformaticsStudent.cpp
deleted file mode 100644
index 9073355..0000000
--- a/Big4_basic_examples/InformaticsStudent/InformaticsStudent.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-#include "InformaticsStudent.h"
-#include <cstring>
-
-
-bool hasDigits(const char* str,int len)
-{
- for (int i = 0; i < len;i++)
- {
- if (str[i] >= '0' && str[i] <= '9')
- return true;
- }
- return false;
-}
-
-void InformaticsStudent::CopyFrom(const InformaticsStudent& other)
-{
- int len = strlen(other.name);
- name = new char[len + 1];
- strcpy(name, other.name); //copy name
- fn = other.fn; //copy fn
-}
-void InformaticsStudent::Free()
-{
- delete[] name;
- fn = 0;
-}
-
-InformaticsStudent::InformaticsStudent()
-{
- name = nullptr;
- fn = 0;
-}
-
-InformaticsStudent::InformaticsStudent(const char* name, int fn) //При конструктура винаги КОПИРАМЕ подадения стринг за нашния нов обект.
-{ // Това е важно, защото не искаме някой друг да има достъп до него.
- setName(name);
- setFn(fn);
-}
-
-
-InformaticsStudent::InformaticsStudent(const InformaticsStudent& other)
-{
- //Използваме функцията, която копира всичко от other в нашия обект.
- CopyFrom(other);
-
- //Понеже това е конструктор, няма нужда да трия нищо от обекта, понеже няма как да е имало данни тук,защото сега го създаваме.
-}
-
-InformaticsStudent& InformaticsStudent::operator=(const InformaticsStudent& other)
-{
- //За разлика от при Копи-контструктора , тука е имало данни , преди копирането
- // (обектът да е съществувал). За това преди да копираме трябва да изтрием това, което е седяло тук.
- // Проверката на 44 ред е с цел да не стане нещо от сорта T1=T1. Това би изтрило данните в обекта, защото първо трием и после
- // присвояваме вече изтритите данни.
-
- if (this != &other)
- {
- Free(); //трия своята памет
-
- CopyFrom(other); // копирам от другия обект
- }
- return *this; // Връщаме указател към обекта, в който сме копирали, за може да chain-ваме T1=T2=T3.
-}
-
-InformaticsStudent::~InformaticsStudent()
-{
- Free();
-}
-
-
-void InformaticsStudent::setName(const char* name)
-{
- delete[] name; //трием данните, които са били тук.
- int len = strlen(name);
- if (hasDigits(name, len))
- {
- this->name[0] = '\0';
- return;
- }
- this->name = new char[len + 1];
- strcpy(this->name, name);
-
-
-}
-void InformaticsStudent::setFn(int fn)
-{
- if (fn < 45000 || fn >45999)
- fn = 45000;
- this->fn = fn;
-}
-const char* InformaticsStudent::getName() const
-{
- return name;
-}
-int InformaticsStudent::getFn() const
-{
- return fn;
-}
-
-void InformaticsStudent::printStudent() const
-{
- std::cout << name << " fn: " << fn << std::endl;
-}
diff --git a/Big4_basic_examples/InformaticsStudent/InformaticsStudent.h b/Big4_basic_examples/InformaticsStudent/InformaticsStudent.h
deleted file mode 100644
index 6e9d743..0000000
--- a/Big4_basic_examples/InformaticsStudent/InformaticsStudent.h
+++ /dev/null
@@ -1,40 +0,0 @@
-
-// Голямта 4-ка - Функции, които трябва да разпишем, САМО когато имаме динамична памет в класа.
-
-// 1.Defualt constructor InformaticsStudent();
-// 2.Copy-constructor InformaticsStudent(const InformaticsStudent& other);
-// 3.operator= InformaticsStudent& operator=(const InformaticsStudent& other);
-// 4.Destructor ~InformaticsStudent()
-// (Най-лесно е като си разпишем функция за копиране CopyFrom и функция за триене Free())
-
-#pragma once
-#include <iostream>
-
-class InformaticsStudent
-{
-private:
- char* name;
- int fn;
-
- void CopyFrom(const InformaticsStudent& other);
- void Free();
-
-public:
- /// BIG 4 starts here
-
- InformaticsStudent();
- InformaticsStudent(const InformaticsStudent& other);
- InformaticsStudent& operator=(const InformaticsStudent& other);
- ~InformaticsStudent();
- // BIG 4 ends here
-
- InformaticsStudent(const char* name, int fn);
-
- void setName(const char* name);
- void setFn(int fn);
- const char* getName() const;
- int getFn() const;
-
- void printStudent() const;
-
-};
diff --git a/Big4_basic_examples/README.md b/Big4_basic_examples/README.md
deleted file mode 100644
index 8b13789..0000000
--- a/Big4_basic_examples/README.md
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/Big4_basic_examples/TestClass/Source.cpp b/Big4_basic_examples/TestClass/Source.cpp
deleted file mode 100644
index bdb8002..0000000
--- a/Big4_basic_examples/TestClass/Source.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <iostream>
-#include "TestClass.h"
-
-using namespace std;
-
-
-int main()
-{
- TestClass obj1(3, 3, "abc");
-
- TestClass obj2(obj1);//copy const;
-
- TestClass obj3(3, 1, "333");
-
- obj3 = obj1; // operator=;
-
- TestClass obj4 = obj3; ////copy const;
-
-
-} //destructors \ No newline at end of file
diff --git a/Big4_basic_examples/TestClass/TestClass.cpp b/Big4_basic_examples/TestClass/TestClass.cpp
deleted file mode 100644
index fe5692b..0000000
--- a/Big4_basic_examples/TestClass/TestClass.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "TestClass.h"
-
-
-TestClass::TestClass() : TestClass(0, 0, "Unknown")
-{
-
-}
-TestClass::TestClass(int a, int b, const char* str)
-{
- this->a = a;
- this->b = b;
- name = new char[strlen(str) + 1];
- strcpy(name, str);
-}
-TestClass::TestClass(const TestClass& other)
-{
- CopyFrom(other);
- //name = other.name NO! only the pointer will be copied.
-}
-
-TestClass& TestClass::operator=(const TestClass& other)
-{
- if (this != &other)
- {
- Free();
- CopyFrom(other);
- }
- return *this; // this TestClass*
-}
-TestClass::~TestClass()
-{
- Free();
-}
-void TestClass::CopyFrom(const TestClass& other)
-{
- name = new char[strlen(other.name) + 1];
- strcpy(name, other.name);
- a = other.a;
- b = other.b;
-}
-void TestClass::Free()
-{
- delete[] name;
- a = b = 0;
-}
diff --git a/Big4_basic_examples/TestClass/TestClass.h b/Big4_basic_examples/TestClass/TestClass.h
deleted file mode 100644
index 4841785..0000000
--- a/Big4_basic_examples/TestClass/TestClass.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <iostream>
-class TestClass
-{
-private:
-
- void CopyFrom(const TestClass& other);
- void Free();
- int a;
- int b;
- char* name;
-
-public:
-
-
- TestClass(int a, int b, const char* str);
-
- // big4
- TestClass();
- TestClass(const TestClass& other);
- TestClass& operator=(const TestClass& other);
- ~TestClass();
-
- void Print() const;
-
-};
diff --git a/Binary_files/BinaryFiles_Cheatsheet.pdf b/Binary_files/BinaryFiles_Cheatsheet.pdf
deleted file mode 100644
index 397177c..0000000
--- a/Binary_files/BinaryFiles_Cheatsheet.pdf
+++ /dev/null
Binary files differ
diff --git a/Binary_files/GetStructsFromBinaryFile.cpp b/Binary_files/GetStructsFromBinaryFile.cpp
deleted file mode 100644
index 011629a..0000000
--- a/Binary_files/GetStructsFromBinaryFile.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <iostream>
-#include <fstream>
-using namespace std;
-
-struct test
-{
- char ch;
- int num;
-};
-
-int GetFileSize(ifstream& ifs)
-{
- ifs.seekg(0, std::ios::end); //отиваме в края на файла
- int size = ifs.tellg(); //запазваме коя е текущата позиция(тя всъщност е и размерът на файла)
- ifs.seekg(0, std::ios::beg); //връщаме се в началото на файла
- return size;
-//тази функция е хубаво да я извикваме преди да сме чели каквото и да е от файла, понеже ще се върнем в началото и ще загубим информация до къде сме стигнали с четенето
-}
-
-
-int main()
-{
- std::ifstream inF("Structs.bat", std::ios::binary);
-
- if (!inF.is_open())
- return false;
-
- int fileSize = GetFileSize(inF); // взимаме големината на файла
- int objectCount = fileSize / sizeof(test); // намираме броя на обектите записани във файла
-
- test* arr = new test[objectCount];
-
- inF.read((char*)arr, fileSize); //директно ги четем в масива
-
- if (!inF)
- {
- cout << "Error occurred while reading from the file";
- return 1;
- }
- inF.close();
-
- for (int i = 0; i < objectCount; i++)
- cout << arr[i].ch << " " << arr[i].num << endl;
- delete[] arr;
-
- return 0;
-} \ No newline at end of file
diff --git a/Binary_files/README.md b/Binary_files/README.md
deleted file mode 100644
index ea56a30..0000000
--- a/Binary_files/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# How does the binary file look like?
-The file after running **SaveStructsToBinaryFile.cpp** or **SaveStructsToBinaryFile(as array).cpp**
-
-![Image of the binary file after running the code](https://i.ibb.co/0JthLd6/3-A978-D14-7-C7-A-4-ABD-8-B0-C-DA27-F6-E9-CD0-A.png "Binary file")
-
diff --git a/Binary_files/SaveAndReadStudents_BinaryFile.cpp b/Binary_files/SaveAndReadStudents_BinaryFile.cpp
deleted file mode 100644
index 0f600aa..0000000
--- a/Binary_files/SaveAndReadStudents_BinaryFile.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <iostream>
-#include <fstream>
-
-using namespace std;
-void SaveStudent(const char* name, int fn, ofstream& f)
-{
- f.write((const char*)&fn, sizeof(int)); //sizeof(int) is 4
- int strLen = strlen(name);
- f.write((const char*)&strLen,sizeof(int));
- f.write(name, strLen);
-}
-void ReadStudent(ifstream& f)
-{
- int fn;
- f.read((char*)&fn, sizeof(int));
-
- int nameLen;
- f.read((char*)&nameLen, sizeof(int));
-
- char* name = new char[nameLen + 1];
- f.read(name, nameLen);
- name[nameLen] = '\0';
-
- cout << "Name: " << name << " Fn: " << fn << endl;
- delete[] name;
-
-}
-
-
-
-int main()
-{
- //ofstream f;
- // f.open("students.bat");
- // SaveStudent("Ivan",123,f);
- // SaveStudent("Sasho",555,f);
- // f.close();
-
- //ifstream f2;
- //f2.open("students.bat");
- //ReadStudent(f2);
- //ReadStudent(f2);
- //f2.close();
-
-
-
-}
diff --git a/Binary_files/SaveStructsToBinaryFile(as array).cpp b/Binary_files/SaveStructsToBinaryFile(as array).cpp
deleted file mode 100644
index 146a93c..0000000
--- a/Binary_files/SaveStructsToBinaryFile(as array).cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-#include <iostream>
-#include <fstream>
-using namespace std;
-
-struct test
-{
- char ch;
- int num;
-};
-
-int main()
-{
-
- test arr[] = { { 'a', 4 }, { 'b', 5 }, { 'c', 6 } };
-
- ofstream outF("Structs.bat", ios::binary);
-
- if (!outF.is_open())
- {
- cout << "Error while opening file" << endl;
- return 1;
- }
-
- outF.write((const char*)&arr, sizeof(arr));
- //можем директно да запазим масива във файла. Резултатът ще същия като от SaveStructToBinaryFile.cpp
-
-
- if (!outF.good())
- {
- cout << "Error occurred while writing the file";
- return 1;
- }
-
- outF.close();
-
- return 0;
-} \ No newline at end of file
diff --git a/Binary_files/SaveStructsToBinaryFile.cpp b/Binary_files/SaveStructsToBinaryFile.cpp
deleted file mode 100644
index 3caad14..0000000
--- a/Binary_files/SaveStructsToBinaryFile.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-#include <iostream>
-#include <fstream>
-using namespace std;
-
-struct test
-{
- char ch;
- int num;
-};
-
-int main()
-{
-
- test obj1{ 'a', 4 };
- test obj2{ 'b', 5 };
- test obj3{ 'c', 6 };
-
- ofstream outF("Structs.bat", ios::binary);
-
- if (!outF.is_open())
- {
- cout << "Error while opening file"<<endl;
- return 1;
- }
-
- //запазваме 3-те обекта във файла
- outF.write((const char*)&obj1, sizeof(test));
- outF.write((const char*)&obj2, sizeof(test));
- outF.write((const char*)&obj3, sizeof(test));
-
- if (!outF.good()) // проверяваме дали след операцията потокът е в невалидено състояние
- {
- cout<<"Error occurred while writing the file";
- return 1;
- }
-
- outF.close();
-
- return 0;
-} \ No newline at end of file
diff --git a/Binary_files/Structs.bat b/Binary_files/Structs.bat
deleted file mode 100644
index 37573c8..0000000
--- a/Binary_files/Structs.bat
+++ /dev/null
Binary files differ
diff --git a/Binary_files/StructsBAT (how does it look).png b/Binary_files/StructsBAT (how does it look).png
deleted file mode 100644
index 5e9e5b3..0000000
--- a/Binary_files/StructsBAT (how does it look).png
+++ /dev/null
Binary files differ
diff --git a/Classes/Distance/Distance.cpp b/Classes/Distance/Distance.cpp
deleted file mode 100644
index aea74a7..0000000
--- a/Classes/Distance/Distance.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-#include "Distance.h"
-
-Distance::Distance()
-{
- setCm(minCM);
- setM(minM);
- setKm(minKm);
-
-}
-Distance::Distance(int km, int m, int cm)
-{
- setCm(cm);
- setM(m);
- setKm(km);
-}
-//constructs the distance by only given cm.
-Distance::Distance(int cm)
-{
- int km = cm / 100000;
- int rest = cm % 100000;
- int m = rest / 100;
- rest = rest % 100;
-
- setKm(km);
- setM(m);
- setCm(rest);
-
-
-}
-void Distance::setCm(int cm)
-{
- if (cm < minCM || cm > maxCM)
- cm = minCM;
- this->cm = cm;
-}
-void Distance::setM(int m)
-{
- if (m < minM || m > maxM)
- m = minM;
- this->m = m;
-}
-void Distance::setKm(int km)
-{
- if (km < minKm)
- km = 0;
- this->km = km;
-}
-int Distance::getCm()const
-{
- return cm;
-}
-int Distance::getM() const
-{
- return m;
-}
-int Distance::getKm() const
-{
- return km;
-}
-void Distance::Print() const
-{
- std::cout << "KM: " << km << " M: " << m << " CM: " << cm << std::endl;
-}
-int Compare(const Distance& d1, const Distance& d2)
-{
- if (d1.getKm() < d2.getKm())
- return -1;
- else if (d1.getKm() > d2.getKm())
- return 1;
- else
- {
- if (d1.getM() < d2.getM())
- return -1;
- else if (d1.getM() > d2.getM())
- return 1;
- else
- {
- if (d1.getCm() < d2.getCm())
- return -1;
- else if (d1.getCm() > d2.getCm())
- return 1;
- else
- return 0;
- }
- }
-}
-// if its between 66km and 99,5 km
-bool Distance::isGreedy() const
-{
- Distance lowLimit(66, 0, 0);
- Distance upLimit(99, 500, 0);
- return Compare(*this, lowLimit) > 0 && Compare(*this, upLimit) < 0;
-}
-int Distance::convertToCm() const
-{
- return cm + m * 100 + km * 100000;
-}
-Distance getDiff(const Distance& d1, const Distance& d2)
-{
- int cm1 = d1.convertToCm();
- int cm2 = d2.convertToCm();
- int diff = abs(cm1 - cm2);
- Distance result(diff);
- return result;
-}
diff --git a/Classes/Distance/Distance.h b/Classes/Distance/Distance.h
deleted file mode 100644
index dfa47d0..0000000
--- a/Classes/Distance/Distance.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <iostream>
-
-const int maxCM = 99;
-const int minCM = 0;
-const int maxM = 999;
-const int minM = 0;
-const int minKm = 0;
-
-class Distance
-{
- int cm;
- int m;
- int km;
-
-public:
- Distance();
- Distance(int km, int m, int cm);
- Distance(int cm);
-
- int getCm() const;
- int getM() const;
- int getKm() const;
-
- void setCm(int cm);
- void setM(int m);
- void setKm(int km);
-
- void Print() const;
- bool isGreedy() const;
- int convertToCm() const;
-};
diff --git a/Classes/GradesBook(DynamicArray)/GradesBook.cpp b/Classes/GradesBook(DynamicArray)/GradesBook.cpp
deleted file mode 100644
index 0c04b83..0000000
--- a/Classes/GradesBook(DynamicArray)/GradesBook.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-#include "GradesBook.h"
-
-
-GradesBook::GradesBook()
-{
- capacity = 4;
- grades = new int[capacity];
- size = 0;
-}
-GradesBook::GradesBook(const GradesBook& other)
-{
- cout << "Copy contr of GradesBook" << endl;
- CopyFrom(other);
-}
-GradesBook& GradesBook::operator=(const GradesBook& other)
-{
- if (this != &other)
- {
- Free();
- CopyFrom(other);
- }
- return *this;
-}
-GradesBook::~GradesBook()
-{
- Free();
-}
-
-
-void GradesBook::CopyFrom(const GradesBook& other)
-{
- grades = new int[other.capacity];
- for (int i = 0; i < other.size; i++)
- grades[i] = other.grades[i];
- capacity = other.capacity;
- size = other.size;
-}
-void GradesBook::Free()
-{
- delete[] grades;
-}
-
-
-bool GradesBook::isFull()
-{
- return size == capacity;
-}
-void GradesBook::AddGrade(int grade)
-{
- if (!isValidGrade(grade))
- return;
- if (isFull())
- Resize();
- grades[size++] = grade;
-
-}
-void GradesBook::Resize()
-{
- int* temp = new int[capacity * 2];
- for (int i = 0; i < size; i++)
- temp[i] = grades[i];
- capacity *= 2;
- delete[] grades;
- grades = temp;
-}
-void GradesBook::RemoveLastGrade()
-{
- size--;
-}
-bool GradesBook::isValidGrade(int grade)
-{
- return (grade >= 2 && grade <= 6);
-}
-int GradesBook::operator[](int index) const
-{
- if (index < 0 || index >= size)
- return -1;
- return grades[index];
-}
-
-ostream& operator<<(ostream& stream, GradesBook& obj)
-{
- for (int i = 0; i < obj.capacity; i++)
- {
- if (i < obj.size)
- stream << obj.grades[i] << ' ';
- else
- stream << '_' << ' ';
- }
- return stream;
-} \ No newline at end of file
diff --git a/Classes/GradesBook(DynamicArray)/GradesBook.h b/Classes/GradesBook(DynamicArray)/GradesBook.h
deleted file mode 100644
index c9ba8e9..0000000
--- a/Classes/GradesBook(DynamicArray)/GradesBook.h
+++ /dev/null
@@ -1,24 +0,0 @@
-class GradesBook
-{
- int* grades;
- int size;
- int capacity;
-
- bool isValidGrade(int grade);
- void Resize();
- void CopyFrom(const GradesBook& other);
- void Free();
-public:
- GradesBook();
- GradesBook(const GradesBook& other);
- GradesBook& operator=(const GradesBook& other);
- ~GradesBook();
-
- bool isFull();
- void AddGrade(int grade);
- void RemoveLastGrade();
-
- int operator[](int index) const;
- friend ostream& operator<<(ostream& stream, GradesBook& obj);
-
-};
diff --git a/Classes/String/String.cpp b/Classes/String/String.cpp
deleted file mode 100644
index f4f567b..0000000
--- a/Classes/String/String.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-#include "String.h"
-
-void String::CopyFrom(const String& other) {
-
- str = new char[strlen(other.str) + 1];
- strcpy(str, other.str);
-
- len = other.len;
-}
-
-void String::Free() {
- delete[] str;
-}
-
-String::String() {
-
- str = new char[1];
- str[0] = '\0';
- len = 0;
-}
-
-inline String::String(char ch)
-{
- str = new char[2];
- str[0] = ch;
- str[1] = '\0';
- len = 1;
-}
-
-String::String(const char* str) {
-
- len = strlen(str);
-
- this->str = new char[len + 1];
- strcpy(this->str, str);
-}
-
-String::String(const String& other) {
- CopyFrom(other);
-}
-
-String& String::operator=(const String& other) {
-
- if (this != &other) {
- Free();
- CopyFrom(other);
- }
- return *this;
-}
-
-String::~String() {
- Free();
-}
-
-int String::getLenght() const {
- return len;
-}
-
-String String::SubString(int start) {
-
- if (start < 0 || start > len)
- throw std::logic_error("Invalid index.\n");
-
- char* newStr = new char[len - start + 2];
- int j = 0;
- for (int i = start; i < len; i++)
- newStr[j++] = str[i];
- newStr[j] = '\0';
-
- String newString(newStr);
- delete[] newStr;
-
- return newString;
-}
-
-String String::SubString(int start, int end) {
-
- if (start < 0 || start > len || end <= 0 || end > len)
- throw std::logic_error("Invalid index.\n");
-
- char* newStr = new char[end - start + 2];
- int j = 0;
- for (int i = start; i <= end; i++)
- newStr[j++] = str[i];
- newStr[j] = '\0';
-
- String newString(newStr);
- delete[] newStr;
-
- return newString;
-}
-
-int String::IndexOf(const String& other, int index) {
-
- if (index < 0)
- throw std::logic_error("Invalid index.\n");
-
- int iter = 0;
- for (int i = index; i <= len; i++) {
-
- if (iter == other.len)
- return i - other.len;
- if (str[i] != other.str[iter])
- iter = 0;
- else
- iter++;
- }
- return -1;
-}
-
-int String::IndexOf(const char* str, int index) {
-
- String searched(str);
- return IndexOf(searched, index);
-}
-
-int String::CountOcurences(String str)
-{
- int count = 0;
- int i = IndexOf(str, 0);
- while (i != -1)
- {
- count++;
- i = IndexOf(str, i + 1);
- }
- return count;
-}
-
-inline int String::GetOcurence(String str, int num)
-{
- int count = 0;
- int i = IndexOf(str, 0);
- while (i != -1)
- {
- count++;
- if (count == num)
- return i;
- i = IndexOf(str, i + 1);
- }
- return count;
-}
-
-const char& String::operator[](int index) const {
-
- if (index >= len)
- throw std::out_of_range("Out of range!");
- return str[index];
-}
-
-char& String::operator[](int index) {
- return str[index];
-}
-
-String& String::operator+=(const String& other) {
-
- char* temp = str;
- str = new char[len + other.len + 1];
- strcpy(str, temp);
- strcat(str, other.str);
- len += other.len;
- delete[] temp;
- return *this;
-}
-
-bool operator==(const String& lhs, const String& rhs) {
- return !strcmp(lhs.str, rhs.str);
-}
-
-bool operator!=(const String& lhs, const String& rhs) {
- return strcmp(lhs.str, rhs.str);
-}
-
-std::ostream& operator<<(std::ostream& os, const String& obj) {
- return os << obj.str;
-}
-
-std::istream& operator>>(std::istream& is, String& obj) {
-
- char buff[MAX_SIZE];
- is.getline(buff, MAX_SIZE);
- obj.str = new char[strlen(buff) + 1];
- strcpy(obj.str, buff);
-
- return is;
-}
-
-
-const String operator+(const String& lhs, const String& rhs) {
- if (lhs.getLenght() == 0)
- return rhs;
- else if (rhs.getLenght() == 0)
- return lhs;
- return String(lhs) += rhs;
-}
diff --git a/Classes/String/String.h b/Classes/String/String.h
deleted file mode 100644
index 37bbc6d..0000000
--- a/Classes/String/String.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef STRING_HDR
-#define STRING_HDR
-
-#include<iostream>
-#include<fstream>
-
-const int MAX_SIZE = 1024;
-
-class String {
-
-private:
- char* str;
- int len;
-
- void CopyFrom(const String& other);
- void Free();
-
-public:
- String();
- String(char ch);
- String(const char* str);
- String(const String& other);
- String& operator=(const String& other);
- ~String();
-
- int getLenght() const;
- String SubString(int start);
- String SubString(int start, int end);
- int IndexOf(const String& other, int index); //return the index of the first encounter of other in the object
- int IndexOf(const char* str, int index); //reusing IndexOf(const String& other, int index)
- int CountOcurences(String str); // How many times a string is found as substring
- int GetOcurence(String str, int i); //Get if the i-th substring (count start from 1)
-
- const char& operator[](int index) const;
- char& operator[](int index);
- String& operator+=(const String& other); //return the concatenation of the object with other
- friend bool operator==(const String& lhs, const String& rhs); //return true if two strings are equivalent
- friend bool operator!=(const String& lhs, const String& rhs); //return true if two strings are not equivalent
- friend std::ostream& operator<<(std::ostream& os, const String& obj);
- friend std::istream& operator>>(std::istream& is, String& obj);
-
- String* Split(String str);
-};
-const String operator+(const String& lhs, const String& rhs);
-#endif // !STRING_HDR \ No newline at end of file
diff --git a/Diamond_problem_and_polymorphism/Chess/Bishop.hpp b/Diamond_problem_and_polymorphism/Chess/Bishop.hpp
deleted file mode 100644
index 014eb48..0000000
--- a/Diamond_problem_and_polymorphism/Chess/Bishop.hpp
+++ /dev/null
@@ -1,34 +0,0 @@
-#pragma once
-#include "Figure.hpp"
-
-class Bishop : virtual public Figure
-{
-public:
- Bishop(int xCoordinate, int yCoordinate, bool isWhite) :Figure(xCoordinate, yCoordinate, isWhite)
- {}
-
- bool Move(int xNew, int yNew);
-
- void Print();
-};
-bool Bishop::Move(int xNew, int yNew)
-{
- if (!isValidCoord(xNew, yNew))
- return false;
- int dx = abs(xCoord - xNew);
- int dy = abs(yCoord - yNew);
- if (dx == dy)
- {
- xCoord = xNew;
- yCoord = yNew;
- return true;
- }
- return false;
-
-
-
-}
-void Bishop::Print()
-{
- cout << 'B';
-} \ No newline at end of file
diff --git a/Diamond_problem_and_polymorphism/Chess/Board.hpp b/Diamond_problem_and_polymorphism/Chess/Board.hpp
deleted file mode 100644
index 95c0f41..0000000
--- a/Diamond_problem_and_polymorphism/Chess/Board.hpp
+++ /dev/null
@@ -1,127 +0,0 @@
-#pragma once
-#include "Figure.hpp"
-#include "Knight.hpp"
-#include "Queen.hpp"
-
-class Board
-{
- Figure*** board;
-
-public:
- Board();
- Board(const Board& other) = delete;
- Board& operator=(const Board& other) = delete;
- ~Board();
- bool isEmptySquare(int x, int y) const;
- bool AddKnight(int x, int y, bool isWhite);
- bool AddQueen(int x, int y, bool isWhite);
- bool AddBishop(int x, int y, bool isWhite);
- bool AddRook(int x, int y, bool isWhite);
-
- void Print();
-
- bool MoveFigure(int xOld, int yOld, int xNew, int yNew);
-
-};
-Board::Board()
-{
- board = new Figure**[8];
- for (int i = 0; i < 8; ++i)
- board[i] = new Figure*[8];
-
- for (int i = 0; i < 8; ++i)
- {
- for (int j = 0; j < 8; j++)
- board[i][j] = nullptr;
- }
-
-}
-
-Board::~Board()
-{
- for (int i = 0; i < 8; ++i)
- {
- for (int j = 0; j < 8; ++j)
- {
- delete board[i][j];
- }
- delete[] board[i];
- }
- delete[] board;
-
-}
-bool Board::isEmptySquare(int x, int y) const
-{
- return board[x][y] == nullptr;
-}
-
-bool Board::AddKnight(int x, int y, bool isWhite)
-{
- if (!isValidCoord(x, y) || !isEmptySquare(x, y))
- return false;
- board[x][y] = new Knight(x, y, isWhite);
- return true;
-}
-bool Board::AddQueen(int x, int y, bool isWhite)
-{
- if (!isValidCoord(x, y) || !isEmptySquare(x, y))
- return false;
- board[x][y] = new Queen(x, y, isWhite);
- return true;
-}
-bool Board::AddBishop(int x, int y, bool isWhite)
-{
- if (!isValidCoord(x, y) || !isEmptySquare(x, y))
- return false;
- board[x][y] = new Bishop(x, y, isWhite);
- return true;
-}
-bool Board::AddRook(int x, int y, bool isWhite)
-{
- if (!isValidCoord(x, y) || !isEmptySquare(x, y))
- return false;
- board[x][y] = new Rook(x, y, isWhite);
- return true;
-}
-
-void Board::Print()
-{
- for (int i = 0; i < 8; ++i)
- {
- for (int j = 0; j < 8; ++j)
- {
- if (!board[i][j])
- cout << '_';
- else
- board[i][j]->Print();
-
- }
- cout << endl;
- }
- cout << endl;
- cout << endl;
-}
-
-bool Board::MoveFigure(int xOld, int yOld, int xNew, int yNew)
-{
- if (isEmptySquare(xOld, yOld)) //Ако няма фигура, там от където искаме да преместим
- return false;
-
- bool res = board[xOld][yOld]->Move(xNew, yNew); //провери дали фигурата може да се премести на съответната прозиция.
- if (!res)// ако не -> лъжа(ходът е невъзможен)
- return false;
-
- if (!isEmptySquare(xNew, yNew))
- {
- if (board[xOld][yOld]->isWhite ^ board[xNew][yNew]->isWhite)// ако там седи фигура от различен цвят
- delete board[xNew][yNew]; //взимаме я(трием обекта)
- else //ако фигурата която седи на новата позиция е от СЪЩИЯ цвят
- {
- board[xOld][yOld]->Move(xOld, yOld); //връщаме обратно кординатите новата фигура. Тук би възникнал проблем, ако имаме фигурата пешка.
- //Това е така, понеже тя няма да може да се върне назад, ако вече е преместена.
- return false; //За това примерно решение е, да се направи функция goBackwards.
- }
- }
- board[xNew][yNew] = board[xOld][yOld];
- board[xOld][yOld] = nullptr;
-} \ No newline at end of file
diff --git a/Diamond_problem_and_polymorphism/Chess/Figure.hpp b/Diamond_problem_and_polymorphism/Chess/Figure.hpp
deleted file mode 100644
index e3fa89d..0000000
--- a/Diamond_problem_and_polymorphism/Chess/Figure.hpp
+++ /dev/null
@@ -1,35 +0,0 @@
-#pragma once
-#include <iostream>
-
-using namespace std;
-
-bool isValidCoord(int xCoord, int yCoord)
-{
- return xCoord >= 0 && xCoord <= 7
- && yCoord >= 0 && yCoord <= 7;
-}
-
-class Figure
-{
-public:
- Figure(int xCoord, int yCoord, bool isWhite);
-
- int xCoord;
- int yCoord;
- bool isWhite;
- virtual bool Move(int xCoord, int yCoord) = 0;
- virtual void Print() = 0;
- virtual ~Figure(){};
-};
-
-Figure::Figure(int xCoord, int yCoord, bool isWhite)
-{
- if (isValidCoord(xCoord, yCoord))
- {
- this->xCoord = xCoord;
- this->yCoord = yCoord;
- this->isWhite = isWhite;
- }
- else
- throw "Ivalid coordinates";
-} \ No newline at end of file
diff --git a/Diamond_problem_and_polymorphism/Chess/Knight.hpp b/Diamond_problem_and_polymorphism/Chess/Knight.hpp
deleted file mode 100644
index 01b9c34..0000000
--- a/Diamond_problem_and_polymorphism/Chess/Knight.hpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#pragma once
-#include "Figure.hpp"
-
-class Knight : public Figure
-{
-public:
- Knight(int xCoordinate, int yCoordinate, bool isWhite) :Figure(xCoordinate, yCoordinate, isWhite)
- {}
-
- bool Move(int xNew, int yNew);
-
- void Print();
-};
-bool Knight::Move(int xNew, int yNew)
-{
- if (!isValidCoord(xNew, yNew))
- return false;
- int possibleX[] = { 1, 1, -1, -1, 2, 2, -2, -2 };
- int possibleY[] = { 2, -2, 2, -2, 1, -1, 1, -1 };
- for (int i = 0; i < 8; ++i)
- {
- if (xNew == xCoord + possibleX[i]
- && yNew == yCoord + possibleY[i])
- {
- xCoord = xNew;
- yCoord = yNew;
- return true;
- }
-
- }
- return false;
-
-}
-
-void Knight::Print()
-{
- cout << 'K';
-} \ No newline at end of file
diff --git a/Diamond_problem_and_polymorphism/Chess/Queen.hpp b/Diamond_problem_and_polymorphism/Chess/Queen.hpp
deleted file mode 100644
index 2f89029..0000000
--- a/Diamond_problem_and_polymorphism/Chess/Queen.hpp
+++ /dev/null
@@ -1,25 +0,0 @@
-#pragma once
-#include "Figure.hpp"
-#include "Bishop.hpp"
-#include "Rook.hpp"
-
-class Queen : public Bishop, public Rook //Формално това НЕ Е ок. Понеже царицата НЕ Е топ и царицата НЕ Е офицер.
-{
-public:
- Queen(int xCoordinate, int yCoordinate, bool isWhite) :Figure(xCoordinate, yCoordinate, isWhite), Bishop(xCoordinate, yCoordinate, isWhite), Rook(xCoordinate, yCoordinate, isWhite)
- {}
- bool Move(int xNew, int yNew);
- void Print();
-};
-
-void Queen::Print()
-{
- cout << 'Q';
-}
-bool Queen::Move(int xNew, int yNew) // Тук сме наследили 2 функционалности. Имаме конфликт, трябва да дефинираме наша(използвайки предишните, ако искаме)
-{
- bool res = Rook::Move(xNew, yNew);//Пробвай да се движиш като топ(по права линия)
- if (res) //Ако е успял - вс е ок
- return true;
- return Bishop::Move(xNew, yNew); //Ако не си успял като топ, пробвай като офицер.
-}
diff --git a/Diamond_problem_and_polymorphism/Chess/README.md b/Diamond_problem_and_polymorphism/Chess/README.md
deleted file mode 100644
index 97ee907..0000000
--- a/Diamond_problem_and_polymorphism/Chess/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-# Chess
-
-Not a full chess project! Just a prototype.
-
diff --git a/Diamond_problem_and_polymorphism/Chess/Rook.hpp b/Diamond_problem_and_polymorphism/Chess/Rook.hpp
deleted file mode 100644
index 5ad81c8..0000000
--- a/Diamond_problem_and_polymorphism/Chess/Rook.hpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#pragma once
-#include "Figure.hpp"
-
-class Rook : virtual public Figure
-{
-
-public:
- Rook(int xCoordinate, int yCoordinate, bool isWhite) :Figure(xCoordinate, yCoordinate, isWhite)
- {}
-
- bool Move(int xNew, int yNew);
-
- void Print();
-
-};
-
-bool Rook::Move(int xNew, int yNew)
-{
- if (!isValidCoord(xNew, yNew))
- return false;
- if (!(xCoord == xNew ^ yCoord == yNew))
- return false;
- xCoord = xNew;
- yCoord = yNew;
- return true;
-}
-
-void Rook::Print()
-{
- cout << 'R';
-} \ No newline at end of file
diff --git a/Diamond_problem_and_polymorphism/Chess/main.cpp b/Diamond_problem_and_polymorphism/Chess/main.cpp
deleted file mode 100644
index 2caaee8..0000000
--- a/Diamond_problem_and_polymorphism/Chess/main.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <iostream>
-#include "Board.hpp"
-using namespace std;
-
-int main()
-{
- while (1)
- {
- Board b;
- b.AddBishop(3, 4, true);
- b.AddKnight(2, 3, false);
- b.Print();
- b.MoveFigure(3, 4, 2, 3);
- b.Print();
- }
-}
diff --git a/Diamond_problem_and_polymorphism/sd b/Diamond_problem_and_polymorphism/sd
deleted file mode 100644
index 6e9f0da..0000000
--- a/Diamond_problem_and_polymorphism/sd
+++ /dev/null
@@ -1 +0,0 @@
-h
diff --git a/Getters_and_setters_simple_examples/Beer/Beer.cpp b/Getters_and_setters_simple_examples/Beer/Beer.cpp
deleted file mode 100644
index 2eaa444..0000000
--- a/Getters_and_setters_simple_examples/Beer/Beer.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-#include "Beer.h"
-
-Beer::Beer(const char* mark, int ml)
-{
- setMark(mark);
- setMl(ml);
-}
-void Beer::printAddress() const
-{
- cout << this << endl;
-}
-void Beer::printBeer() const
-{
- cout << mark << " " << ml << endl;
-}
-void Beer::setMl(int ml)
-{
- if (ml < MINBEERML)
- ml = MINBEERML;
- else if (ml > MAXBEERML)
- ml = MAXBEERML;
- this->ml = ml;
-}
-void Beer::setMark(const char* mark)
-{
- int len = strlen(mark);
-
- if (len >= 20 || len == 0) //àêî íè äàäàò íåâàëèäíà ìàðêà íà áèðàòà (ñòðèíã ñ äúëæèíà >= 20 )
- this->mark[0] = '\0'; //ïðàâèì ìàðêàòà äà å ïðàçíèÿ ñòðèíã
- else
- strcpy(this->mark, mark);
-}
-int Beer::getMl() const
-{
- return ml;
-}
-const char* Beer::getMark() const
-{
- return mark;
-}
-
-
-
diff --git a/Getters_and_setters_simple_examples/Beer/Beer.h b/Getters_and_setters_simple_examples/Beer/Beer.h
deleted file mode 100644
index 4bc8adc..0000000
--- a/Getters_and_setters_simple_examples/Beer/Beer.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#include <iostream>
-using namespace std;
-
-const int MAXBEERML = 500;
-const int MINBEERML = 330;
-
-class Beer
-{
-public:
- Beer(const char* mark, int ml);
-
- void printAddress() const;
-
- void printBeer() const;
- void setMl(int ml);
-
- void setMark(const char* mark);
-
- int getMl() const; // const сложен тук означава, че метода не променя член-данните на класа.Съответно можем да го викаме от константни обекти
-
- const char* getMark() const;
-
-private:
-
- char mark[20]; //Стринг с максимална дължина 19, понеже 1 символ ни трябва за '\0'
- int ml;
-};
diff --git a/Getters_and_setters_simple_examples/Beer/main.cpp b/Getters_and_setters_simple_examples/Beer/main.cpp
deleted file mode 100644
index 9e6801d..0000000
--- a/Getters_and_setters_simple_examples/Beer/main.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "Beer.h"
-
-int main()
-{
- Beer t("Zagorka", 5); // 5 å íåâàëèäíî êîëè÷åñòâî áèðà. Íî â êîíñòðóêòîðà èçâèêâàìå setML, êîÿòî ñå ãðèæè â ïðîìåíëèâàòà äà íå ïîïàäíàò íåâàëèäíè äàííè.
- t.setMl(330);
- t.printBeer();
-} \ No newline at end of file
diff --git a/Getters_and_setters_simple_examples/Daily_schedule/Event.cpp b/Getters_and_setters_simple_examples/Daily_schedule/Event.cpp
deleted file mode 100644
index 084c7b3..0000000
--- a/Getters_and_setters_simple_examples/Daily_schedule/Event.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-#include "Event.h"
-
-
-Event::Event() :start(0, 0, 0), end(0, 0, 0), isInit(false)
-{ }
-Event::Event(const char* name, int startHours, int startMin, int startSec, int endHours, int endMin, int endSec) : start(startHours, startMin, startSec), end(endHours, endMin, endSec)
-{
- if (!IsValid())
- end = start;
- strcpy(this->name, name);
-
-}
-void Event::print() const
-{
- std::cout << name << std::endl;
- std::cout << "start: ";
- start.print();
- std::cout << "end: ";
- end.print();
-}
-const Time& Event::getStart() const
-{
- return start;
-}
-const Time& Event::getEnd() const
-{
- return end;
-}
-const char* Event::getName() const
-{
- return name;
-}
-bool Event::getIsInit() const
-{
- return isInit;
-}
-bool Event::IsValid()
-{
- return start.CompareTo( end) >= 0;
-} \ No newline at end of file
diff --git a/Getters_and_setters_simple_examples/Daily_schedule/Event.h b/Getters_and_setters_simple_examples/Daily_schedule/Event.h
deleted file mode 100644
index 32c332d..0000000
--- a/Getters_and_setters_simple_examples/Daily_schedule/Event.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#include "Time.h"
-
-class Event
-{
- char name[30];
- Time start;
- Time end;
- bool isInit;
-public:
- Event();
- Event(const char* name, int startHours, int startMin, int startSec, int endHours, int endMin, int endSec);
- bool IsValid();
- void print() const;
- const Time& getStart() const;
- const Time& getEnd() const;
- const char* getName() const;
- bool getIsInit() const;
-};
-
diff --git a/Getters_and_setters_simple_examples/Daily_schedule/Schedule.cpp b/Getters_and_setters_simple_examples/Daily_schedule/Schedule.cpp
deleted file mode 100644
index b4c9017..0000000
--- a/Getters_and_setters_simple_examples/Daily_schedule/Schedule.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "Schedule.h"
-
-int Schedule::getFirstFreeSlotIndex()
-{
- for (int i = 0; i < MAXEVENTS; i++)
- {
- if (!events[i].getIsInit())
- return i;
- }
- return -1;
-}
-void Schedule::DeleteEvent(int ind)
-{
- Event emptyEvent;
- events[ind] = emptyEvent;
-}
-
-bool Schedule::AddEvent(const char* name, int startHours, int startMin, int startSec, int endHours, int endMin, int endSec)
-{
- int freeIndex = getFirstFreeSlotIndex();
- if (freeIndex == -1)
- return false;
- Event eventToAdd(name, startHours, startMin, startSec, endHours, endMin, endSec);
- events[freeIndex] = eventToAdd;
-
- return true;
-}
-bool Schedule::RemoveEvent(const char* name)
-{
- for (int i = 0; i < MAXEVENTS; i++)
- {
- if (strcmp(events[i].getName(), name) == 0)
- {
- DeleteEvent(i);
- return true;
- }
- }
- return false;
-}
-bool Schedule::RemoveEvent(int startHours, int startMin, int startSec, int endHours, int endMin, int endSec)
-{
- Time startToRemove(startHours, startMin, startSec);
- Time endToRemove(endHours, endMin, endSec);
-
- for (int i = 0; i < MAXEVENTS; i++)
- {
- if ((events[i].getStart().CompareTo(startToRemove)) == 0 && (events[i].getEnd().CompareTo(endToRemove) == 0))
- {
- DeleteEvent(i);
- return true;
- }
- }
- return false;
-}
-void Schedule::Print() const
-{
- for (int i = 0; i < MAXEVENTS; i++)
- {
- if (events[i].getIsInit())
- events[i].print();
- }
-} \ No newline at end of file
diff --git a/Getters_and_setters_simple_examples/Daily_schedule/Schedule.h b/Getters_and_setters_simple_examples/Daily_schedule/Schedule.h
deleted file mode 100644
index 2ad2c7a..0000000
--- a/Getters_and_setters_simple_examples/Daily_schedule/Schedule.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#include "Event.h"
-
-const int MAXEVENTS = 10;
-class Schedule
-{
-private:
- Event events[MAXEVENTS];
-
- int getFirstFreeSlotIndex();
- void DeleteEvent(int ind);
-
-
-public:
- bool AddEvent(const char* name, int startHours, int startMin, int startSec, int endHours, int endMin, int endSec);
- bool RemoveEvent(const char* name);
- bool RemoveEvent(int startHours, int startMin, int startSec, int endHours, int endMin, int endSec);
- void Print() const;
- bool isValidSchedule() const;
-};
diff --git a/Getters_and_setters_simple_examples/Daily_schedule/Source.cpp b/Getters_and_setters_simple_examples/Daily_schedule/Source.cpp
deleted file mode 100644
index 678eb98..0000000
--- a/Getters_and_setters_simple_examples/Daily_schedule/Source.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-#include <iostream>
-using namespace std;
-
-
-#include "Schedule.h"
- //àáñòðàêöèÿ
- //êàïñóëàöèÿ ->
-
-// äíåâåí Îðã -> ñúáèòèÿ
-// Ñúáèòèå -> íà÷àëåí ÷àñ è êðàåí ÷àñ
-// Ìîäèôèêàòîðè çà äîñòúï: private, public:
-// Êëàñ: Ñòðóêòóðà, ïðè êîÿòî ìîä. çà äîñòúï å private ïî default
-
-
-
-int main()
-{
-
- Schedule s;
-
- cout<< s.AddEvent("Party", 22, 30, 00, 23, 30, 00);
-
- cout<< s.AddEvent("Uni", 12, 00, 00, 14, 00, 00);
-
- s.AddEvent("Lunch", 11, 30, 00, 12, 00, 00);
- s.Print();
- cout << "after remove"<<endl;
- s.RemoveEvent(12,00,00,14,00,00);
-
- s.Print();
-
-
-
-
-
-
-} \ No newline at end of file
diff --git a/Getters_and_setters_simple_examples/Daily_schedule/Time.cpp b/Getters_and_setters_simple_examples/Daily_schedule/Time.cpp
deleted file mode 100644
index f4fc702..0000000
--- a/Getters_and_setters_simple_examples/Daily_schedule/Time.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-#include "Time.h"
-
-Time::Time(int hours, int mins, int seconds)
-{
- setHours(hours);
- setMins(mins);
- setSeconds(seconds);
-}
-/*Time()
-{
-setHours(0);
-setMins(0);
-setSeconds(0);
-}*/
-int Time::getSeconds() const
-{
- return seconds;
-}
-int Time::getMins() const
-{
- return mins;
-}
-int Time::getHours() const
-{
- return hours;
-}
-void Time::print() const
-{
- std::cout << hours << " " << mins << " " << seconds << std::endl;
-}
-void Time::setSeconds(int seconds)
-{
- if (seconds < 0 || seconds > 59)
- seconds = 0;
- this->seconds = seconds;
-}
-void Time::setMins(int mins)
-{
- if (mins < 0 || mins > 59)
- mins = 0;
- this->mins = mins;
-}
-void Time::setHours(int hours)
-{
- if (hours < 0 || hours > 23)
- hours = 0;
- this->hours = hours;
-}
-int Time::CompareTo(const Time& other) const
-{
- if (getHours() > other.getHours())
- return -1;
- else if (getHours() < other.getHours())
- {
- return 1;
- }
- else
- {
- if (getMins() > other.getMins())
- return -1;
- else if (getMins() < other.getMins())
- return 1;
- else
- {
- if (getSeconds() > other.getSeconds())
- return -1;
- else if (getSeconds() < other.getSeconds())
- return 1;
- else
- return 0;
- }
- }
-} \ No newline at end of file
diff --git a/Getters_and_setters_simple_examples/Daily_schedule/Time.h b/Getters_and_setters_simple_examples/Daily_schedule/Time.h
deleted file mode 100644
index 97529e0..0000000
--- a/Getters_and_setters_simple_examples/Daily_schedule/Time.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <iostream>
-
-class Time
-{
- int seconds;
- int mins;
- int hours;
-public:
- Time(int hours, int mins, int seconds);
- //Time();
- int getSeconds() const;
- int getMins() const;
- int getHours() const;
- void setSeconds(int seconds);
- void setMins(int mins);
- void setHours(int hours);
-
- void print() const;
-
- int CompareTo(const Time& other) const;
-};
diff --git a/Homework_tasks/Homework_1.pdf b/Homework_tasks/Homework_1.pdf
deleted file mode 100644
index 8383550..0000000
--- a/Homework_tasks/Homework_1.pdf
+++ /dev/null
Binary files differ
diff --git a/Homework_tasks/Homework_2.pdf b/Homework_tasks/Homework_2.pdf
deleted file mode 100644
index d36ee1b..0000000
--- a/Homework_tasks/Homework_2.pdf
+++ /dev/null
Binary files differ
diff --git a/Operator_overloading/Complex/Complex.hpp b/Operator_overloading/Complex/Complex.hpp
deleted file mode 100644
index 8a6edd5..0000000
--- a/Operator_overloading/Complex/Complex.hpp
+++ /dev/null
@@ -1,136 +0,0 @@
-#include <iostream>
-class Complex
-{
-private:
- double real;
- double im;
-
-public:
- Complex();
- Complex(double real, double im);
-
- Complex getConjugated() const; //връща комплексно спрегнатото число на текущия обект.
-
- //assignment operators
- // a+=b Към а се добавя стойността на b. а се променя , b не се. Операцията ще върне a за да може да се правят верижни изрази (a+=b+=c)
- Complex& operator+=(const Complex&);
- Complex& operator-=(const Complex&);
- Complex& operator*=(const Complex&);
- Complex& operator/=(const Complex&);
-
-
-
- //stream opeartors ( std::cout>> c1) (std::cin<<c1 )
- friend std::ostream& operator<<(std::ostream&, const Complex&);
- friend std::istream& operator>>(std::istream&, Complex&);
-
-};
-// a+b. Операторът връща НОВА променлива(Complex), която е резултатът от операцията.
-Complex operator+(const Complex&, const Complex&);
-Complex operator-(const Complex&, const Complex&);
-Complex operator*(const Complex&, const Complex&);
-Complex operator/(const Complex&, const Complex&);
-
-
-
-Complex::Complex()
-{
- real = 0;
- im = 0;
-}
-Complex::Complex(double real, double im)
-{
- this->real = real;
- this->im = im;
-}
-Complex& Complex::operator+=(const Complex& other)
-{
- real += other.real;
- im += other.im;
- return *this;
-}
-Complex& Complex::operator-=(const Complex& other)
-{
- real -= other.real;
- im -= other.im;
- return *this;
-}
-Complex& Complex::operator*=(const Complex& other)
-{
- int oldReal = real;
- real = real*other.real - im*other.im;
- im = oldReal*other.im + im * other.real;
- return *this;
-}
-Complex& Complex::operator/=(const Complex& other) // a/=b
-{
- Complex Conjugated = other.getConjugated(); //взимаме комплексно спрегнатата на другата дроб (b)
-
- Complex otherCopy(other);// копираме другата (b), за да не я промяняме.
-
- //Умножаваме двете по комплексно спрегнатата.
- *this *= Conjugated;
- otherCopy *= Conjugated; //Тук трябва да остане само реална част.
-
- if (otherCopy.real != 0)
- {
- real /= otherCopy.real;
- im /= otherCopy.real;
- }
-
- return *this;
-}
-
-//След дефинирането на +=, -=, *= и /=, можем лесно да дефинираме +, -, * и /, преизползвайки вече написаните опратори.
-
-
-Complex operator+(const Complex& lhs, const Complex& rhs) { //a+b
-
- Complex result(lhs); // Създаваме нов обект, който е копие на a (използваме копи-конструктора)
- result += rhs; //към копието на a, добавяме b (Използваме вече дефинирания оператор +=)
-
- return result;
-}
-//Операторите -, *, / са аналогични с +.
-Complex operator-(const Complex& lhs, const Complex& rhs) {
- Complex result(lhs);
- result -= rhs;
-
- return result;
-}
-
-Complex operator*(const Complex& lhs, const Complex& rhs) {
-
- Complex result(lhs);
- result *= rhs;
-
- return result;
-}
-
-Complex operator/(const Complex& lhs, const Complex& rhs) {
-
- Complex result(lhs);
- result /= rhs;
-
- return result;
-}
-
-Complex Complex::getConjugated() const
-{
- Complex result(*this);
- result.im *= -1;
-
- return result;
-}
-
-// за да можем да правим cout<<c1 или да запазваме във файл и др.
-std::ostream& operator<<(std::ostream& ofs, const Complex& r) {
-
- return ofs << r.real << ' ' << r.im << 'i';
-}
-
-// за да можем да правим cin>>c1 или да четем от файл и др.
-std::istream& operator>>(std::istream& ifs, Complex& r) {
-
- return ifs >> r.real >> r.im;
-}
diff --git a/Operator_overloading/Vector/Source.cpp b/Operator_overloading/Vector/Source.cpp
deleted file mode 100644
index c2e3c70..0000000
--- a/Operator_overloading/Vector/Source.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <iostream>
-#include "Vector.h"
-int main()
-{
-
-
- Vector v1(2);
-
- std::cin >> v1;
-
- std::cout << (v1);
-
-
-}
diff --git a/Operator_overloading/Vector/Vector.cpp b/Operator_overloading/Vector/Vector.cpp
deleted file mode 100644
index 5059a66..0000000
--- a/Operator_overloading/Vector/Vector.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-#include "Vector.h"
-
-Vector::Vector() :coordinates(nullptr), length(0)
-{}
-Vector::Vector(int len)
-{
- coordinates = new int[len];
- for (int i = 0; i < len; i++)
- coordinates[i] = 0;
- length = len;
-}
-void Vector::CopyFrom(const Vector& other)
-{
- coordinates = new int[other.length];
- for (int i = 0; i < other.GetLen(); i++)
- coordinates[i] = other.coordinates[i];
- length = other.length;
-}
-void Vector::Free()
-{
- delete[] coordinates;
- length = 0;
-}
-Vector::Vector(const Vector& other)
-{
- CopyFrom(other);
-}
-Vector& Vector::operator=(const Vector& other)
-{
- if (this != &other)
- {
- Free();
- CopyFrom(other);
- }
- return *this;
-}
-Vector::~Vector()
-{
- Free();
-}
-
-int& Vector::operator[](int index)
-{
- if (index < length)
- return coordinates[index];
- else
- throw 0;
-}
-void Vector::print()
-{
- std::cout << '(';
- for (int i = 0; i < length; i++)
- std::cout << coordinates[i]<<" ";
- std::cout <<')' <<std::endl;
-}
-
-int Vector::GetLen() const
-{
- return length;
-}
-int Vector::GetAtIndex(int index) const
-{
- if (index<length)
- return coordinates[index];
- else
- return 0;
-}
-Vector& Vector::operator+=(const Vector& other)
-{
- if (GetLen() != other.GetLen())
- throw "Invalid operation";
- for (int i = 0; i < other.length; i++)
- coordinates[i] += other.coordinates[i];
- return *this;
-}
-
-Vector& Vector::operator-=(const Vector& other)
-{
- if (GetLen() != other.GetLen())
- throw "Invalid operation";
- for (int i = 0; i < other.length; ++i)
- coordinates[i] -= other.coordinates[i];
- return *this;
-}
-
-Vector& Vector::operator*=(int scalar)
-{
- for (int i = 0; i < length; i++)
- coordinates[i] *= scalar;
- return *this;
-}
-Vector operator+(const Vector& lhs,const Vector& rhs)
-{
- Vector temp(lhs);
- temp += rhs;
- return temp;
-}
-
-Vector operator-(const Vector& lhs, const Vector& rhs)
-{
- Vector temp(lhs);
- temp -= rhs;
- return temp;
-}
-
-int operator%(const Vector& lhs, const Vector& rhs)
-{
- int min = lhs.GetLen() < rhs.GetLen() ? lhs.GetLen() : rhs.GetLen();
- int result = 0;
- for (int i = 0; i < min; i++)
- result += lhs.GetAtIndex(i) * rhs.GetAtIndex(i);
- return result;
-}
-bool operator||(const Vector& lhs, const Vector& rhs)// a и b са перпендикулярни <-> a*K=b (K е константа).
-{
- double coeff = lhs.GetAtIndex(0) / rhs.GetAtIndex(0);
- for (int i = 1; i < lhs.GetLen(); i++)
- {
- if (lhs.GetAtIndex(i) == 0 || rhs.GetAtIndex(i) == 0)
- continue;
- double Newfirst = lhs.GetAtIndex(i);
- double Newcoeff = Newfirst / rhs.GetAtIndex(i);
- if (abs(Newcoeff-coeff)>0.01)
- return false;
- }
- return true;
-}
-bool operator|=(const Vector& lhs, const Vector& rhs)
-{
- return lhs%rhs == 0; //скаларното произведение на два успоредни вектора е 0.
-}
-
-std::ostream& operator<<(std::ostream& os, const Vector& v)
-{
- for (int i = 0; i < v.GetLen(); ++i)
- os << v.GetAtIndex(i) << " ";
- return os;
-}
-
-std::istream& operator>>(std::istream& ifs, Vector& v)
-{
- for (int i = 0; i < v.GetLen(); ++i)
- ifs >> v[i];
- return ifs;
-}
diff --git a/Operator_overloading/Vector/Vector.h b/Operator_overloading/Vector/Vector.h
deleted file mode 100644
index 9026d73..0000000
--- a/Operator_overloading/Vector/Vector.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#include <iostream>
-class Vector
-{
-private:
- int* coordinates;
- int length;
- void CopyFrom(const Vector& other);
- void Free();
-public:
- Vector();
- Vector(int len);
-
- Vector(const Vector& other);
- Vector& operator=(const Vector& other);
- ~Vector();
-
- int GetLen() const;
-
- Vector& operator+=(const Vector& other);
- Vector& operator-=(const Vector& other);
- Vector& operator*=(int);
-
- friend std::ostream& operator<<(std::ostream&, const Vector& v);
- friend std::istream& operator>>(std::istream&, Vector& v);
-
- int GetAtIndex(int index) const;
- int& operator[](int index);// оператор за индексиране(като в масивите) vector a; a[4] -взима четвъртия координат на вектора
- void print();
-};
-
-Vector operator+(const Vector& lhs, const Vector& rhs);// Събиране на два вектора
-Vector operator-(const Vector& lhs, const Vector& rhs);// Изваждане на два вектора
-
-int operator%(const Vector& lhs, const Vector& rhs); // Скаларно произведение на два вектора
-
-bool operator||(const Vector& lhs, const Vector& rhs); // Дали два вектора са успоредни
-bool operator|=(const Vector& lhs, const Vector& rhs); // Дали два вектора са перпендикулярни
diff --git a/Polymorphism/Farm(cloneFunction)/Animal.hpp b/Polymorphism/Farm(cloneFunction)/Animal.hpp
deleted file mode 100644
index 0f290ca..0000000
--- a/Polymorphism/Farm(cloneFunction)/Animal.hpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#pragma once
-#include <iostream>
-#include <string>
-using namespace std;
-class Animal
-{
-
- string name;
-public:
- Animal(string name)
- {
- this->name = name;
- }
- virtual void Roar() = 0;
- virtual Animal* clone() = 0; // Всеки наследник се копира по различен начин.
- // За това правим тази виртуална функция и всеки наследник да окаже как се копират данните му.
- virtual ~Animal() {};
-
-};
diff --git a/Polymorphism/Farm(cloneFunction)/Cat.hpp b/Polymorphism/Farm(cloneFunction)/Cat.hpp
deleted file mode 100644
index eba7ff0..0000000
--- a/Polymorphism/Farm(cloneFunction)/Cat.hpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "Animal.hpp"
-#include <iostream>
-
-class Cat : public Animal
-{
-public:
- Cat(string name) :Animal(name)
- {}
- Animal* clone()
- {
- Animal* copy = new Cat(*this);
- return copy;
- }
- void Roar()
- {
- std::cout << "meow meow" << std::endl;
- }
-};
diff --git a/Polymorphism/Farm(cloneFunction)/Cow.hpp b/Polymorphism/Farm(cloneFunction)/Cow.hpp
deleted file mode 100644
index ba576a2..0000000
--- a/Polymorphism/Farm(cloneFunction)/Cow.hpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "Animal.hpp"
-class Cow : public Animal
-{
-public:
- Cow(string name) :Animal(name)
- {}
- Animal* clone()
- {
- Animal* copy = new Cow(*this);
- return copy;
- }
- void Roar()
- {
- std::cout << "muu mmuu" << std::endl;
- }
-};
diff --git a/Polymorphism/Farm(cloneFunction)/Dog.hpp b/Polymorphism/Farm(cloneFunction)/Dog.hpp
deleted file mode 100644
index 9928c2a..0000000
--- a/Polymorphism/Farm(cloneFunction)/Dog.hpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "Animal.hpp"
-
-class Dog : public Animal
-{
-public:
- Dog(string name) :Animal(name)
- {}
- void Roar()
- {
- std::cout << "bau bau" << std::endl;
- }
- Animal* clone()
- {
- Animal* copy = new Dog(*this);
- return copy;
- }
-
-};
diff --git a/Polymorphism/Farm(cloneFunction)/Farm.hpp b/Polymorphism/Farm(cloneFunction)/Farm.hpp
deleted file mode 100644
index 1ad3be5..0000000
--- a/Polymorphism/Farm(cloneFunction)/Farm.hpp
+++ /dev/null
@@ -1,106 +0,0 @@
-#include "Animal.hpp"
-#include "Cat.hpp"
-#include "Dog.hpp"
-#include "Cow.hpp"
-// Collection of all animals
-class Farm
-{
- Animal** animals;
-
- int len;
- int count;
-
- void Free();
- void CopyFrom(const Farm& other);
-
- bool AddAnimal(Animal* an);
-public:
- Farm(int len);
- Farm(const Farm& other);
- Farm& operator=(const Farm& other);
- ~Farm();
-
- bool AddCat(std::string name);
- bool AddDog(std::string name);
- bool AddCow(std::string name);
-
- void RoarAll();
-};
-Farm::Farm(int len)
-{
- animals = new Animal*[len];
- this->len = len;
- count = 0;
-}
-Farm::Farm(const Farm& other)
-{
- CopyFrom(other);
-}
-Farm& Farm::operator=(const Farm& other)
-{
- if (this != &other)
- {
- Free();
- CopyFrom(other);
- }
- return *this;
-}
-Farm::~Farm()
-{
- Free();
-}
-bool Farm::AddAnimal(Animal* an)
-{
- if(count == len)
- return false;
- animals[count++]=an;
- return true;
-}
-bool Farm::AddCat(std::string name)
-{
- Cat* c = new Cat(name);
- if(!AddAnimal(c))
- {
- delete c;
- return false;
- }
-}
-bool Farm::AddDog(std::string name)
-{
- Dog* c = new Dog(name);
- if(!AddAnimal(c))
- {
- delete c;
- return false;
- }
-}
-bool Farm::AddCow(std::string name)
-{
- Cow* c = new Cow(name);
- if(!AddAnimal(c))
- {
- delete c;
- return false;
- }
-}
-void Farm::RoarAll()
-{
- for (int i = 0; i < count; i++)
- animals[i]->Roar(); //roar is a virtual function
-
-}
-void Farm::Free()
-{
- for (int i = 0; i < count; i++)
- delete animals[i]; //~Animal() is virtual
- delete[] animals;
-}
-void Farm::CopyFrom(const Farm& other)
-{
- animals = new Animal*[other.len];
- for (int i = 0; i < other.count; i++)
- animals[i] = other.animals[i]->clone(); //clone is a virtual function
- len = other.len;
- count = other.count;
-}
-
diff --git a/Polymorphism/Farm(cloneFunction)/Source.cpp b/Polymorphism/Farm(cloneFunction)/Source.cpp
deleted file mode 100644
index d6fcfc9..0000000
--- a/Polymorphism/Farm(cloneFunction)/Source.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "Farm.hpp"
-
-using namespace std;
-int main()
-{
- Farm f(4);
- f.AddCat("Cat1");
- f.AddCat("Cat2");
- f.AddCow("Cow1");
- f.AddDog("Dog1");
-
- f.RoarAll();
-}
diff --git a/Polymorphism/MathExpression/Expression.hpp b/Polymorphism/MathExpression/Expression.hpp
deleted file mode 100644
index 4f09790..0000000
--- a/Polymorphism/MathExpression/Expression.hpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#pragma once
-
-#include <iostream>
-
-class Expression
-{
-public:
- virtual void Print() = 0;
- virtual int Evaluate() = 0;
- virtual ~Expression(){}
- int getType(){ return type; }
-protected:
- int type; //Ако обектът е NUM, ще пазим тук 1, а ако обектът е Операция, ще пазим тук 2.
-};
-
-
diff --git a/Polymorphism/MathExpression/Num.hpp b/Polymorphism/MathExpression/Num.hpp
deleted file mode 100644
index 91e1492..0000000
--- a/Polymorphism/MathExpression/Num.hpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#pragma once
-
-#include "Expression.hpp"
-class Num : public Expression
-{
- int number;
-public:
- Num(int number)
- {
- this->number = number;
- type = 1;
- }
- void Print()
- {
- std::cout << number;
- }
- int Evaluate()
- {
- return number;
- }
- int getNum()
- {
- return number;
- }
-
-}; \ No newline at end of file
diff --git a/Polymorphism/MathExpression/Operation.hpp b/Polymorphism/MathExpression/Operation.hpp
deleted file mode 100644
index ade8404..0000000
--- a/Polymorphism/MathExpression/Operation.hpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#pragma once
-#include "Expression.hpp"
-class Operation : public Expression
-{
-
-public:
- Expression* left;
- char op;
- Expression* right;
- Operation(Expression* left, char ch, Expression* right)
- {
-
- this->left = left;
- op = ch;
- this->right = right;
- type = 2;
-
- }
- void Print()
- {
- std::cout << '(';
- left->Print();
- std::cout << op;
- right->Print();
- std::cout << ')';
- }
- int Evaluate()
- {
- int result = left->Evaluate();
- int value2 = right->Evaluate();
-
- if (op == '+')
- result += value2;
- else if (op == '*')
- result *= value2;
- else
- return 0; //Invalid operation
- return result;
- }
- ~Operation()
- {
-
- delete left;
- delete right;
- op = '\0';
- }
-
-}; \ No newline at end of file
diff --git a/Polymorphism/MathExpression/README.md b/Polymorphism/MathExpression/README.md
deleted file mode 100644
index 4472fb4..0000000
--- a/Polymorphism/MathExpression/README.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# Hierarchy
-
-
-![enter image description here](https://i.ibb.co/ZHnWnKG/1-hierarchy.jpg "Hierarchy")
-
-# How does an object looks like
-
-![enter image description here](https://i.ibb.co/KFfsf7S/2-Example-Expr.jpg "Example")
diff --git a/Polymorphism/MathExpression/main.hpp b/Polymorphism/MathExpression/main.hpp
deleted file mode 100644
index 5fa3f8f..0000000
--- a/Polymorphism/MathExpression/main.hpp
+++ /dev/null
@@ -1,43 +0,0 @@
-#include "Expression.hpp"
-#include "Num.hpp"
-#include "Operation.hpp"
-bool AreTheSame(Expression* left, Expression* right);
-int main()
-{
- Expression* l = new Num(3);
- Expression* r = new Num(7);
- Expression* final1 = new Operation(l, '+', r);
-
- Expression* l2 = new Num(3);
- Expression* r2 = new Num(7);
- Expression* final2 = new Operation(l2, '+', r2);
-
- std::cout << final1->Evaluate();
-
- std::cout << AreTheSame(final1, final2);
-
- delete final1, final2; //Винаги трием най-големите 'Expression-и'. Те се грижат за по-малките от които са образувани.
-
-
-
-}
-bool AreTheSame(Expression* left, Expression* right)
-{
- if (left->getType() != right->getType())//гледаме дали не са от раличен тип (едното да е опрация,другото да е число)
- return false; //очевидно са различни тогава
-
- if (left->getType() == 1) //ако двете са числа
- {
- Num* l = (Num*)left; //Конвертираме пойнтерите
- Num* r = (Num*)right;
- return l->getNum() == r->getNum(); //сравняваме стойностите
- }
- else //Ако двете са операции
- {
- Operation* l = (Operation*)left;
- Operation* r = (Operation*)right;
- return (l->op == l->op) && AreTheSame(l->left, r->left) && AreTheSame(l->right, r->right);
- //гледаме дали знаците на опрациите съвпадат, дали левите страни съвпадат и дали десните страни съвпадат.
- }
-
-}
diff --git a/Polymorphism/Shapes/Circle.cpp b/Polymorphism/Shapes/Circle.cpp
deleted file mode 100644
index e625123..0000000
--- a/Polymorphism/Shapes/Circle.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#include "Circle.h"
-
-Circle::Circle(int x, int y, int r) : Shape(1), radius(r)
-{
- setPoint(x, y, 0);
-}
-double Circle::getArea()
-{
- return PI * radius * radius;
-}
-double Circle::getPer()
-{
- return 2 * PI * radius;
-}
-Shape* Circle::clone()
-{
- Circle* newCircle = new Circle(*this);
- return newCircle;
-} \ No newline at end of file
diff --git a/Polymorphism/Shapes/Circle.h b/Polymorphism/Shapes/Circle.h
deleted file mode 100644
index c648690..0000000
--- a/Polymorphism/Shapes/Circle.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "Shape.h"
-
-const double PI = 3.14;
-class Circle : public Shape
-{
-
- int radius;
-public:
- Circle(int x, int y, int radius);
-
- double getArea();
- double getPer();
-
- Shape* clone();
-
-}; \ No newline at end of file
diff --git a/Polymorphism/Shapes/Point.h b/Polymorphism/Shapes/Point.h
deleted file mode 100644
index acacb85..0000000
--- a/Polymorphism/Shapes/Point.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#pragma once
-#include <iostream>
-struct Point
-{
- int x;
- int y;
- Point(int x, int y)
- {
- this->x = x;
- this->y = y;
- }
- Point() : Point(0,0)
- {}
- double getDist(const Point& other) const
- {
- return sqrt((x - other.x)*(x - other.x) + (y - other.y) * (y - other.y));
- }
-}; \ No newline at end of file
diff --git a/Polymorphism/Shapes/Rectangle.cpp b/Polymorphism/Shapes/Rectangle.cpp
deleted file mode 100644
index b684c50..0000000
--- a/Polymorphism/Shapes/Rectangle.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "Rectangle.h"
-
-
-Rectangle::Rectangle(int x1, int y1, int x3, int y3) : Shape(4)
-{
- setPoint(x1, y1, 0);
- setPoint(x3, y3, 2);
- setPoint(x1, y3, 1);
- setPoint(x3, y1, 3);
-}
-
-double Rectangle::getPer()
-{
- return 2 * (getPoint(0).getDist(getPoint(1)) + getPoint(1).getDist(getPoint(2)) );
-}
-double Rectangle::getArea()
-{
- return getPoint(0).getDist(getPoint(1)) * getPoint(1).getDist(getPoint(2));
-}
-Shape* Rectangle::clone()
-{
- Rectangle* newRect = new Rectangle(*this);
- return newRect;
-} \ No newline at end of file
diff --git a/Polymorphism/Shapes/Rectangle.h b/Polymorphism/Shapes/Rectangle.h
deleted file mode 100644
index 681a021..0000000
--- a/Polymorphism/Shapes/Rectangle.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "Shape.h"
-class Rectangle : public Shape
-{
-public:
- Rectangle(int x1, int y1, int x3, int y3);
-
- double getPer();
- double getArea();
-
- Shape* clone();
-}; \ No newline at end of file
diff --git a/Polymorphism/Shapes/Shape.cpp b/Polymorphism/Shapes/Shape.cpp
deleted file mode 100644
index 0751108..0000000
--- a/Polymorphism/Shapes/Shape.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#include "Shape.h"
-
-Shape::Shape(int pointsCount)
-{
- points = new Point[pointsCount];
- this->pointsCount = pointsCount;
-}
-
-void Shape::setPoint(int x, int y, int ind)
-{
- Point current(x, y);
- points[ind] = current;
-
-}
-
-const Point& Shape::getPoint(int ind)
-{
- return points[ind];
-}
-
-void Shape::CopyFrom(const Shape& other)
-{
- points = new Point[other.pointsCount];
- pointsCount = other.pointsCount;
-
- for (int i = 0; i < pointsCount; i++)
- points[i] = other.points[i];
-}
-void Shape::Free()
-{
- delete[] points;
- pointsCount = 0;
-}
-Shape::Shape(const Shape& other)
-{
- CopyFrom(other);
-}
-Shape& Shape::operator=(const Shape& other)
-{
- if (this != &other)
- {
- Free();
- CopyFrom(other);
- }
- return *this;
-}
-Shape::~Shape()
-{
- Free();
-}
diff --git a/Polymorphism/Shapes/Shape.h b/Polymorphism/Shapes/Shape.h
deleted file mode 100644
index f31e42e..0000000
--- a/Polymorphism/Shapes/Shape.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#pragma once
-
-#include "Point.h"
-
-class Shape
-{
- Point* points;
- int pointsCount;
-
- void CopyFrom(const Shape& other);
- void Free();
-
-public:
- Shape(int pointsCount);
- Shape(const Shape& other);
- Shape& operator=(const Shape& other);
- virtual ~Shape();
-
- void setPoint(int x, int y, int ind);
- const Point& getPoint(int ind);
-
- virtual double getPer() =0;
- virtual double getArea() = 0;
-
- virtual Shape* clone() = 0;
-
-}; \ No newline at end of file
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
diff --git a/Polymorphism/Shapes/ShapeCollection.h b/Polymorphism/Shapes/ShapeCollection.h
deleted file mode 100644
index 36f6092..0000000
--- a/Polymorphism/Shapes/ShapeCollection.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#include "Circle.h"
-#include "Rectangle.h"
-#include "Triangle.h"
-
-class ShapeCollection
-{
- Shape** data;
- int count;
- int capacity;
-
- void Resize();
-
- void Add(Shape* currentShape);
-
- void CopyFrom(const ShapeCollection& other);
- void Free();
-public:
- ShapeCollection();
-
- ShapeCollection(const ShapeCollection& other);
- ShapeCollection& operator=(const ShapeCollection& other);
- ~ShapeCollection();
-
- void AddCircle(int x1,int x2,int r);
- void AddTriagnle(int x1,int y1,int x2,int y2,int x3,int y3);
- void AddRect(int x1, int y1, int x2, int y2);
-
- void PrintAllAreas();
- void PrintAllPers();
-}; \ No newline at end of file
diff --git a/Polymorphism/Shapes/Source.cpp b/Polymorphism/Shapes/Source.cpp
deleted file mode 100644
index 3381111..0000000
--- a/Polymorphism/Shapes/Source.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-
-using namespace std;
-#include <fstream>
-#include <vector>
-#include "ShapeCollection.h"
-
-int main()
-{
- ShapeCollection sh;
-
- sh.AddCircle(3, 3, 5);
- sh.AddTriagnle(1, 4, 2, 11, 7, 4);
- sh.AddRect(1, 1, 4, 4);
-
- sh.PrintAllAreas();
-
-/* lamda fucntion example
- std::vector<Circle> s;
- s.push_back(Circle(3, 4, 4));
- s.push_back(Circle(1, 2, 3));
-
- std::sort(s.begin(), s.end(),
- [](Circle& lhs, Circle& rhs) -> bool
- {
- return lhs.getArea() < rhs.getArea();
- });*/
-
-
-
-} \ No newline at end of file
diff --git a/Polymorphism/Shapes/Triangle.cpp b/Polymorphism/Shapes/Triangle.cpp
deleted file mode 100644
index 545e2a6..0000000
--- a/Polymorphism/Shapes/Triangle.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "Triangle.h"
-
-Triangle::Triangle(int x1, int y1, int x2, int y2, int x3, int y3) : Shape(3)
-{
- setPoint(x1, y1, 0);
- setPoint(x2, y2, 1);
- setPoint(x3, y3, 2);
-}
-
-double Triangle::getArea()
-{
- double sideA = getPoint(0).getDist(getPoint(1));
- double sideB = getPoint(1).getDist(getPoint(2));
- double sideC = getPoint(2).getDist(getPoint(0));
-
- double halfPer = getPer() / 2;
-
- return sqrt(halfPer * (halfPer - sideA) *
- (halfPer - sideB) * (halfPer - sideC));
-}
-double Triangle::getPer()
-{
- return getPoint(0).getDist(getPoint(1)) +
- getPoint(1).getDist(getPoint(2)) +
- getPoint(2).getDist(getPoint(0));
-}
-Shape* Triangle::clone()
-{
- Triangle* newTriangle = new Triangle(*this);
- return newTriangle;
-} \ No newline at end of file
diff --git a/Polymorphism/Shapes/Triangle.h b/Polymorphism/Shapes/Triangle.h
deleted file mode 100644
index b038e80..0000000
--- a/Polymorphism/Shapes/Triangle.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#include "Shape.h"
-
-class Triangle : public Shape
-{
-public:
- Triangle(int x1, int y1, int x2, int y2, int x3, int y3);
-
- double getArea();
- double getPer();
-
- Shape* clone();
-}; \ No newline at end of file
diff --git a/README.md b/README.md
index 5ddb799..243a7fd 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-### Код от семинарите по "Обектно-ориентирано програмиране"
-### -спец. Информатика, ФМИ
+### Код от семинарите по СДП - спец. Компютърни науки - летен семестър 2020/2021
-![enter image description here](https://i.ibb.co/4V0sNg9/programa.png "Учебна програма")
+
+ - **Тема 1** \ No newline at end of file
diff --git a/Smart_pointers/1. uniqe_ptr.cpp b/Smart_pointers/1. uniqe_ptr.cpp
deleted file mode 100644
index a865776..0000000
--- a/Smart_pointers/1. uniqe_ptr.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-#include <iostream>
-#include <memory>
-
-using namespace std;
-
-class Test
-{
-public:
- Test()
- {
- cout<<"Test()"<<endl;
- }
- Test(const Test& other)
- {
- cout<<"Copy constructor"<<endl;
- }
- Test& operator=(const Test& other)
- {
- cout<< "Assignment operator" <<endl;
- }
- ~Test()
- {
- cout<<"Detructor"<<endl;
- }
- void f()
- {
-
- }
-
-};
-int main()
-{
- {
- unique_ptr<Test> smart_pointer_1(new Test()); //Test()
-
- smart_pointer_1->f(); // Достъпваме данните, както с обикновен пойнтер.
-
- Test* obj = smart_pointer_1.get(); //От тук иматаме достъп до паметта, към която сочи пойнтера.
- //delete obj; // Това не трябва да се прави! smart_pointer_1 не знае, че паметта е освободена и ще се опита да я освободи, което ще доведе до грешка!
-
- } // Detructor (Паметта се освобождава сама след премахването на пойнтера)
-
- {
-
- unique_ptr<Test> smart_pointer_2(new Test());
-
- unique_ptr<Test> smart_pointer_3 = move(smart_pointer_2);
- // unique_ptr<Test> smart_pointer_3(smart_pointer_2); //този синтаксис (както и оператор =) не е валиден! Те бяха валидни в стария и не толкова иползван auto_ptr.
-
- smart_pointer_2.get(); // Това ще даде NULL, защото smart_pointer_3 "открадна" обекта на smart_pointer_2
-
- }
-
-
- return 0;
-}
diff --git a/Smart_pointers/2. shared_ptr.cpp b/Smart_pointers/2. shared_ptr.cpp
deleted file mode 100644
index b8437a8..0000000
--- a/Smart_pointers/2. shared_ptr.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-#include <iostream>
-#include <memory>
-
-using namespace std;
-
-class Test
-{
-public:
- Test()
- {
- cout << "Test()" << endl;
- }
- Test(const Test& other)
- {
- cout << "Copy constructor" << endl;
- }
- Test& operator=(const Test& other)
- {
- cout << "Assignment operator" << endl;
- }
- ~Test()
- {
- cout << "Detructor" << endl;
- }
-
-};
-int main()
-{
-
-
- shared_ptr<Test> smart_pointer_1(new Test());
-
- cout << smart_pointer_1.get() << endl; //адресът на обекта.
-
- shared_ptr<Test> smart_pointer_2(smart_pointer_1);
-
- cout << smart_pointer_1.get() << endl; //За разлика от uniqe_ptr, тук smart_pointer_1 ПРОДЪЛЖАВА да сочи към обекта.
-
- cout << smart_pointer_2.use_count() << endl; //може да видим колко пойнтера са насочени към обекта.
- // Обектът ще се изтрие, когато пойнтерите станат 0.
-
-
- {
- shared_ptr<Test> smart_pointer_3 = smart_pointer_2;
-
- cout << smart_pointer_1.use_count() << endl; //3 пойнтера към обекта ни.
-
- }
- cout << smart_pointer_1.use_count() << endl; // 2, защото smart_pointer_3 вече го няма.
-
- return 0;
-} //тук изчезват пойнтерите -> броят им става 0 и обекта се изтрива(изтрива се от последния пойнтер преди да изчезне)
-//Възможно е да се получи цикличност. Един shared_ptr да реферира друг shared_ptr, който обратно да реферира първия! Как да се справим с проблема ще видим в точка 3. (weak_ptr)
diff --git a/Smart_pointers/3. weak_ptr.cpp b/Smart_pointers/3. weak_ptr.cpp
deleted file mode 100644
index 044985a..0000000
--- a/Smart_pointers/3. weak_ptr.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <iostream>
-#include <memory>
-
-using namespace std;
-
-class Test
-{
-public:
- Test()
- {
- cout << "Test()" << endl;
- }
- Test(const Test& other)
- {
- cout << "Copy constructor" << endl;
- }
- Test& operator=(const Test& other)
- {
- cout << "Assignment operator" << endl;
- }
- ~Test()
- {
- cout << "Detructor" << endl;
- }
- void f()
- {
-
- }
-
-};
-int main()
-{
-
-
- shared_ptr<Test> smart_pointer_1(new Test());
-
- cout << smart_pointer_1.get() << endl; //адресът на обекта.
-
- weak_ptr<Test> smart_pointer_2(smart_pointer_1);
-
- cout << smart_pointer_2.use_count() << endl; // 1 - weak_ptr НЕ участва в бройката на пойнтерите към обектите.
-
- //smart_pointer_2->f(); ГРЕШКА!
- //Това е само за временно пазане на адреса! НЕ МОЖЕМ да достъпим данните. Ако искате да достъпите данните на този пойнтер трябва да го превърнете(заключте) в shared_ptr!.
-
- shared_ptr<Test> smart_pointer_3 = smart_pointer_2.lock(); //.lock() връща shared_ptr към обекта.
-
- cout << smart_pointer_1.use_count() << endl;//2
-
- smart_pointer_3->f(); // .. и тн.
-
-}
diff --git a/Templates/Queue/Queue.hpp b/Templates/Queue/Queue.hpp
deleted file mode 100644
index 128f1df..0000000
--- a/Templates/Queue/Queue.hpp
+++ /dev/null
@@ -1,121 +0,0 @@
-#ifndef QUEUE_HDR
-#define QUEUE_HDR
-
-#include <iostream>
-using namespace std;
-
-template<typename T>
-class Queue {
-private:
- T * arr;
- int capacity;
- int count;
-
- int whereToPut;
- int whereToGet;
- void Resize();
- void CopyFrom(const Queue<T>& other);
- void Free();
-
-public:
- Queue();
- Queue(const Queue<T>& other);
- Queue<T>& operator=(const Queue<T>& other);
- ~Queue();
-
- bool isEmpty() const;
- void Push(T el);
- T Pop();
- T& Peek();
-};
-
-template <typename T>
-void Queue<T>::Resize() {
- T* temp = new T[capacity * 2];
- for (int i = 0; i < capacity; ++i)
- temp[i] = Pop();
- whereToGet = 0;
- whereToPut = capacity;
- count = capacity;
- capacity *= 2;
- delete[] arr;
- arr = temp;
-}
-
-template <typename T>
-void Queue<T>::CopyFrom(const Queue<T>& other) {
- arr = new T[other.capacity];
- for (int i = 0; i < other.count; ++i)
- arr[i] = other.arr[i];
- count = other.count;
- capacity = other.capacity;
- whereToPut = other.whereToPut;
- whereToGet = other.whereToGet;
-}
-
-template <typename T>
-void Queue<T>::Free() {
- delete[] arr;
- count = capacity = 0;
-}
-
-template <typename T>
-Queue<T>::Queue() {
- arr = new T[4];
- capacity = 4;
- count = 0;
- whereToPut = 0;
- whereToGet = 0;
-}
-
-template <typename T>
-Queue<T>::Queue(const Queue<T>& other) {
- CopyFrom(other);
-}
-
-template <typename T>
-Queue<T>& Queue<T>::operator=(const Queue<T>& other) {
- if (this != &other) {
- Free();
- CopyFrom(other);
- }
- return *this;
-}
-
-template <typename T>
-Queue<T>::~Queue() {
- Free();
-}
-
-template <typename T>
-bool Queue<T>::isEmpty() const {
- return count == 0;
-}
-
-template <typename T>
-void Queue<T>::Push(T el) {
- if (count == capacity)
- Resize();
- arr[whereToPut] = el;
- (whereToPut += 1) %= capacity;
- count++;
-}
-
-template <typename T>
-T Queue<T>::Pop() {
- if (count == 0)
- throw "Queue is empty";
- T elToReturn = arr[whereToGet];
- count--;
- (whereToGet += 1) %= capacity;
- return elToReturn;
-}
-
-template <typename T>
-T& Queue<T>::Peek() {
- if (isEmpty())
- throw std::logic_error("empty queue");
- return arr[whereToGet];
-}
-
-#endif // !QUEUE_HDR
diff --git a/Templates/Queue/main.cpp b/Templates/Queue/main.cpp
deleted file mode 100644
index 89b8468..0000000
--- a/Templates/Queue/main.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "Queue.hpp"
-
-
-int main()
-{
- Queue<int> q;
- q.Enqueue(3);
- q.Dequeue();
- q.Enqueue(1);
- q.Enqueue(2);
- q.Enqueue(3);
- q.Enqueue(4);
- q.Enqueue(5);
- q.Enqueue(6);
- cout<<q.Dequeue();
-
- cout << q.Dequeue();
- cout << q.Dequeue();
- cout << q.Dequeue();
- cout << q.Dequeue();
- cout << q.Dequeue();
- return 0;
-}
diff --git a/Templates/test.txt b/Templates/test.txt
deleted file mode 100644
index e69de29..0000000
--- a/Templates/test.txt
+++ /dev/null