Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit112a0d344da9e66d20ee9ab5d488e59c5d52e6ad (patch)
Author
 Angeld55 <angel_dimitriev@abv.bg>
2020-04-09 18:09:42 +0300
Committer
 Angeld55 <angel_dimitriev@abv.bg>
2020-04-09 18:09:42 +0300
Filese3bb9cf17c24a3b53c746d9142906d550d549465
Object-oriented_programming_FMI-112a0d344da9e66d20ee9ab5d488e59c5d52e6ad.tar
Object-oriented_programming_FMI-112a0d344da9e66d20ee9ab5d488e59c5d52e6ad.tar.gz
Object-oriented_programming_FMI-112a0d344da9e66d20ee9ab5d488e59c5d52e6ad.zip
Parentec26fab32d144b436d08f9da6049bd053156d783 (diff)
added new examples
65 files changed, 1708 insertions, 1116 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_inheritance/Drinks/AlcoholDrink.cpp (renamed from Big4AndInheritance/Drinks/AlcoholDrink.cpp)36
-rw-r--r--Big4_and_inheritance/Drinks/AlcoholDrink.h (renamed from Big4AndInheritance/Drinks/AlcoholDrink.h)28
-rw-r--r--Big4_and_inheritance/Drinks/Drink.cpp (renamed from Big4AndInheritance/Drinks/Drink.cpp)126
-rw-r--r--Big4_and_inheritance/Drinks/Drink.h (renamed from Big4AndInheritance/Drinks/Drink.h)42
-rw-r--r--Big4_and_inheritance/Drinks/main.cpp (renamed from Big4AndInheritance/Drinks/main.cpp)20
-rw-r--r--Big4_and_inheritance/Students/GradesBook.cpp (renamed from Big4AndInheritance/Students/GradesBook.cpp)180
-rw-r--r--Big4_and_inheritance/Students/GradesBook.h (renamed from Big4AndInheritance/Students/GradesBook.h)54
-rw-r--r--Big4_and_inheritance/Students/Student.cpp (renamed from Big4AndInheritance/Students/Student.cpp)18
-rw-r--r--Big4_and_inheritance/Students/Student.h (renamed from Big4AndInheritance/Students/Student.h)30
-rw-r--r--Big4_and_inheritance/Students/User.cpp (renamed from Big4AndInheritance/Students/User.cpp)84
-rw-r--r--Big4_and_inheritance/Students/User.h (renamed from Big4AndInheritance/Students/User.h)36
-rw-r--r--Big4_basic_examples/InformaticsStudent/InformaticsStudent.cpp (renamed from Big4/InformaticsStudent.cpp)0
-rw-r--r--Big4_basic_examples/InformaticsStudent/InformaticsStudent.h (renamed from Big4/InformaticsStudent.h)0
-rw-r--r--Big4_basic_examples/README.md (renamed from Big4/README.md)0
-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.pdf (renamed from BinaryFiles/BinaryFiles_Cheatsheet.pdf)bin61351 -> 61351 bytes
-rw-r--r--Binary_files/GetStructsFromBinaryFile.cpp (renamed from BinaryFiles/GetStructsFromBinaryFile.cpp)92
-rw-r--r--Binary_files/README.md (renamed from BinaryFiles/README.md)0
-rw-r--r--Binary_files/SaveAndReadStudents_BinaryFile.cpp (renamed from BinaryFiles/SaveAndReadStudents_BinaryFile.cpp)0
-rw-r--r--Binary_files/SaveStructsToBinaryFile(as array).cpp (renamed from BinaryFiles/SaveStructsToBinaryFile(as array).cpp)72
-rw-r--r--Binary_files/SaveStructsToBinaryFile.cpp (renamed from BinaryFiles/SaveStructsToBinaryFile.cpp)78
-rw-r--r--Binary_files/Structs.bat (renamed from BinaryFiles/Structs.bat)bin24 -> 24 bytes
-rw-r--r--Binary_files/StructsBAT (how does it look).png (renamed from BinaryFiles/StructsBAT (how does it look).png)bin6050 -> 6050 bytes
-rw-r--r--Classes/String/String.cpp (renamed from Classes/String/String.hpp)62
-rw-r--r--Classes/String/String.h45
-rw-r--r--Classes/Triangle/Triangle.hpp36
-rw-r--r--Classes/Triangle/point.hpp23
-rw-r--r--Diamond_problem_and_polymorphism/Chess/Bishop.hpp (renamed from DiamondProblemAndPolymorphism/Chess/Bishop.hpp)66
-rw-r--r--Diamond_problem_and_polymorphism/Chess/Board.hpp (renamed from DiamondProblemAndPolymorphism/Chess/Board.hpp)252
-rw-r--r--Diamond_problem_and_polymorphism/Chess/Figure.hpp (renamed from DiamondProblemAndPolymorphism/Chess/Figure.hpp)68
-rw-r--r--Diamond_problem_and_polymorphism/Chess/Knight.hpp (renamed from DiamondProblemAndPolymorphism/Chess/Knight.hpp)74
-rw-r--r--Diamond_problem_and_polymorphism/Chess/Queen.hpp (renamed from DiamondProblemAndPolymorphism/Chess/Queen.hpp)50
-rw-r--r--Diamond_problem_and_polymorphism/Chess/README.md (renamed from DiamondProblemAndPolymorphism/Chess/README.md)0
-rw-r--r--Diamond_problem_and_polymorphism/Chess/Rook.hpp (renamed from DiamondProblemAndPolymorphism/Chess/Rook.hpp)60
-rw-r--r--Diamond_problem_and_polymorphism/Chess/main.cpp (renamed from DiamondProblemAndPolymorphism/Chess/main.cpp)0
-rw-r--r--Diamond_problem_and_polymorphism/sd (renamed from DiamondProblemAndPolymorphism/sd)0
-rw-r--r--GetAndSet/Beer.hpp74
-rw-r--r--Getters_and_setter_simple_examples/Beer/Beer.cpp43
-rw-r--r--Getters_and_setter_simple_examples/Beer/Beer.h27
-rw-r--r--Getters_and_setter_simple_examples/Beer/main.cpp8
-rw-r--r--Getters_and_setter_simple_examples/Daily_schedule/Event.cpp40
-rw-r--r--Getters_and_setter_simple_examples/Daily_schedule/Event.h19
-rw-r--r--Getters_and_setter_simple_examples/Daily_schedule/Schedule.cpp62
-rw-r--r--Getters_and_setter_simple_examples/Daily_schedule/Schedule.h19
-rw-r--r--Getters_and_setter_simple_examples/Daily_schedule/Source.cpp37
-rw-r--r--Getters_and_setter_simple_examples/Daily_schedule/Time.cpp73
-rw-r--r--Getters_and_setter_simple_examples/Daily_schedule/Time.h21
-rw-r--r--Homework_tasks/Homework_1.pdf (renamed from Homeworks/Homework_1.pdf)bin137954 -> 137954 bytes
-rw-r--r--Homework_tasks/Homework_2.pdf (renamed from Homeworks/Homework_2.pdf)bin145320 -> 145320 bytes
-rw-r--r--Operator_overloading/Complex/Complex.hpp (renamed from OperatorOverloading/Complex/Complex.hpp)0
-rw-r--r--Operator_overloading/Vector/Source.cpp (renamed from OperatorOverloading/Vector/Source.cpp)28
-rw-r--r--Operator_overloading/Vector/Vector.cpp (renamed from OperatorOverloading/Vector/Vector.cpp)290
-rw-r--r--Operator_overloading/Vector/Vector.h (renamed from OperatorOverloading/Vector/Vector.h)74
-rw-r--r--Templates/Queue/Queue.hpp (renamed from Templates/Queue.hpp)0
-rw-r--r--Templates/Queue/main.cpp (renamed from Templates/main.cpp)0
-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
new file mode 100644
index 0000000..f5dd3e3
--- /dev/null
+++ b/Big4_and_composition/Airlines_booking_system/Airline.cpp
@@ -0,0 +1,110 @@
+#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
new file mode 100644
index 0000000..0a8f34c
--- /dev/null
+++ b/Big4_and_composition/Airlines_booking_system/Airline.h
@@ -0,0 +1,28 @@
+#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
new file mode 100644
index 0000000..d9f0c25
--- /dev/null
+++ b/Big4_and_composition/Airlines_booking_system/Airport.cpp
@@ -0,0 +1,56 @@
+#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
new file mode 100644
index 0000000..98b3547
--- /dev/null
+++ b/Big4_and_composition/Airlines_booking_system/Airport.h
@@ -0,0 +1,22 @@
+#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
new file mode 100644
index 0000000..b7436a3
--- /dev/null
+++ b/Big4_and_composition/Airlines_booking_system/Flight.cpp
@@ -0,0 +1,27 @@
+#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
new file mode 100644
index 0000000..177aeaa
--- /dev/null
+++ b/Big4_and_composition/Airlines_booking_system/Flight.h
@@ -0,0 +1,21 @@
+#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
new file mode 100644
index 0000000..6d84dbd
--- /dev/null
+++ b/Big4_and_composition/Airlines_booking_system/Source.cpp
@@ -0,0 +1,23 @@
+
+#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/Big4AndInheritance/Drinks/AlcoholDrink.cpp b/Big4_and_inheritance/Drinks/AlcoholDrink.cpp
index db3619c..0e20087 100644
--- a/Big4AndInheritance/Drinks/AlcoholDrink.cpp
+++ b/Big4_and_inheritance/Drinks/AlcoholDrink.cpp
@@ -1,18 +1,18 @@
-#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;
-}
+#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/Big4AndInheritance/Drinks/AlcoholDrink.h b/Big4_and_inheritance/Drinks/AlcoholDrink.h
index 1bf3d66..0bd1d10 100644
--- a/Big4AndInheritance/Drinks/AlcoholDrink.h
+++ b/Big4_and_inheritance/Drinks/AlcoholDrink.h
@@ -1,14 +1,14 @@
-#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;
-};
+#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/Big4AndInheritance/Drinks/Drink.cpp b/Big4_and_inheritance/Drinks/Drink.cpp
index a2933ad..709446b 100644
--- a/Big4AndInheritance/Drinks/Drink.cpp
+++ b/Big4_and_inheritance/Drinks/Drink.cpp
@@ -1,63 +1,63 @@
-#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;
-}
+#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/Big4AndInheritance/Drinks/Drink.h b/Big4_and_inheritance/Drinks/Drink.h
index c02398b..db93c97 100644
--- a/Big4AndInheritance/Drinks/Drink.h
+++ b/Big4_and_inheritance/Drinks/Drink.h
@@ -1,21 +1,21 @@
-#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;
-};
+#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/Big4AndInheritance/Drinks/main.cpp b/Big4_and_inheritance/Drinks/main.cpp
index 6c67b96..c809123 100644
--- a/Big4AndInheritance/Drinks/main.cpp
+++ b/Big4_and_inheritance/Drinks/main.cpp
@@ -1,10 +1,10 @@
-#include "AlcoholDrink.h"
-int main()
-{
- AlcoholDrink DR1("Spirt", 100, 98);
-
- AlcoholDrink dr2 (DR1);
- dr2.getMark();
-
-
-}
+#include "AlcoholDrink.h"
+int main()
+{
+ AlcoholDrink DR1("Spirt", 100, 98);
+
+ AlcoholDrink dr2 (DR1);
+ dr2.getMark();
+
+
+}
diff --git a/Big4AndInheritance/Students/GradesBook.cpp b/Big4_and_inheritance/Students/GradesBook.cpp
index 759a63c..6d3de27 100644
--- a/Big4AndInheritance/Students/GradesBook.cpp
+++ b/Big4_and_inheritance/Students/GradesBook.cpp
@@ -1,91 +1,91 @@
-#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;
+#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/Big4AndInheritance/Students/GradesBook.h b/Big4_and_inheritance/Students/GradesBook.h
index e1dd262..e63e92f 100644
--- a/Big4AndInheritance/Students/GradesBook.h
+++ b/Big4_and_inheritance/Students/GradesBook.h
@@ -1,27 +1,27 @@
-#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);
-
-};
+#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/Big4AndInheritance/Students/Student.cpp b/Big4_and_inheritance/Students/Student.cpp
index e3d5f06..4734529 100644
--- a/Big4AndInheritance/Students/Student.cpp
+++ b/Big4_and_inheritance/Students/Student.cpp
@@ -1,10 +1,10 @@
-#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);
+#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/Big4AndInheritance/Students/Student.h b/Big4_and_inheritance/Students/Student.h
index 45a103d..aafaf58 100644
--- a/Big4AndInheritance/Students/Student.h
+++ b/Big4_and_inheritance/Students/Student.h
@@ -1,15 +1,15 @@
-#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);
-
-
-};
+#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/Big4AndInheritance/Students/User.cpp b/Big4_and_inheritance/Students/User.cpp
index 27947b1..93d34b6 100644
--- a/Big4AndInheritance/Students/User.cpp
+++ b/Big4_and_inheritance/Students/User.cpp
@@ -1,43 +1,43 @@
-#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;
+#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/Big4AndInheritance/Students/User.h b/Big4_and_inheritance/Students/User.h
index d84bd71..400057b 100644
--- a/Big4AndInheritance/Students/User.h
+++ b/Big4_and_inheritance/Students/User.h
@@ -1,18 +1,18 @@
-#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();
-};
+#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/InformaticsStudent.cpp b/Big4_basic_examples/InformaticsStudent/InformaticsStudent.cpp
index 9073355..9073355 100644
--- a/Big4/InformaticsStudent.cpp
+++ b/Big4_basic_examples/InformaticsStudent/InformaticsStudent.cpp
diff --git a/Big4/InformaticsStudent.h b/Big4_basic_examples/InformaticsStudent/InformaticsStudent.h
index 6e9d743..6e9d743 100644
--- a/Big4/InformaticsStudent.h
+++ b/Big4_basic_examples/InformaticsStudent/InformaticsStudent.h
diff --git a/Big4/README.md b/Big4_basic_examples/README.md
index 8b13789..8b13789 100644
--- a/Big4/README.md
+++ b/Big4_basic_examples/README.md
diff --git a/Big4_basic_examples/TestClass/Source.cpp b/Big4_basic_examples/TestClass/Source.cpp
new file mode 100644
index 0000000..bdb8002
--- /dev/null
+++ b/Big4_basic_examples/TestClass/Source.cpp
@@ -0,0 +1,20 @@
+#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
new file mode 100644
index 0000000..fe5692b
--- /dev/null
+++ b/Big4_basic_examples/TestClass/TestClass.cpp
@@ -0,0 +1,45 @@
+#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
new file mode 100644
index 0000000..4841785
--- /dev/null
+++ b/Big4_basic_examples/TestClass/TestClass.h
@@ -0,0 +1,25 @@
+#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/BinaryFiles/BinaryFiles_Cheatsheet.pdf b/Binary_files/BinaryFiles_Cheatsheet.pdf
index 397177c..397177c 100644
--- a/BinaryFiles/BinaryFiles_Cheatsheet.pdf
+++ b/Binary_files/BinaryFiles_Cheatsheet.pdf
Binary files differ
diff --git a/BinaryFiles/GetStructsFromBinaryFile.cpp b/Binary_files/GetStructsFromBinaryFile.cpp
index 2d91189..011629a 100644
--- a/BinaryFiles/GetStructsFromBinaryFile.cpp
+++ b/Binary_files/GetStructsFromBinaryFile.cpp
@@ -1,47 +1,47 @@
-#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;
+#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/BinaryFiles/README.md b/Binary_files/README.md
index f740e9f..f740e9f 100644
--- a/BinaryFiles/README.md
+++ b/Binary_files/README.md
diff --git a/BinaryFiles/SaveAndReadStudents_BinaryFile.cpp b/Binary_files/SaveAndReadStudents_BinaryFile.cpp
index 0f600aa..0f600aa 100644
--- a/BinaryFiles/SaveAndReadStudents_BinaryFile.cpp
+++ b/Binary_files/SaveAndReadStudents_BinaryFile.cpp
diff --git a/BinaryFiles/SaveStructsToBinaryFile(as array).cpp b/Binary_files/SaveStructsToBinaryFile(as array).cpp
index b8d5cfe..146a93c 100644
--- a/BinaryFiles/SaveStructsToBinaryFile(as array).cpp
+++ b/Binary_files/SaveStructsToBinaryFile(as array).cpp
@@ -1,37 +1,37 @@
-#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;
+#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/BinaryFiles/SaveStructsToBinaryFile.cpp b/Binary_files/SaveStructsToBinaryFile.cpp
index 5e03b44..3caad14 100644
--- a/BinaryFiles/SaveStructsToBinaryFile.cpp
+++ b/Binary_files/SaveStructsToBinaryFile.cpp
@@ -1,40 +1,40 @@
-#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;
+#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/BinaryFiles/Structs.bat b/Binary_files/Structs.bat
index 37573c8..37573c8 100644
--- a/BinaryFiles/Structs.bat
+++ b/Binary_files/Structs.bat
Binary files differ
diff --git a/BinaryFiles/StructsBAT (how does it look).png b/Binary_files/StructsBAT (how does it look).png
index 5e9e5b3..5e9e5b3 100644
--- a/BinaryFiles/StructsBAT (how does it look).png
+++ b/Binary_files/StructsBAT (how does it look).png
Binary files differ
diff --git a/Classes/String/String.hpp b/Classes/String/String.cpp
index b2c333f..f4f567b 100644
--- a/Classes/String/String.hpp
+++ b/Classes/String/String.cpp
@@ -1,48 +1,4 @@
-#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);
-
+#include "String.h"
void String::CopyFrom(const String& other) {
@@ -107,10 +63,10 @@ String String::SubString(int start) {
char* newStr = new char[len - start + 2];
int j = 0;
- for (int i = start; i < len; i++)
+ for (int i = start; i < len; i++)
newStr[j++] = str[i];
newStr[j] = '\0';
-
+
String newString(newStr);
delete[] newStr;
@@ -136,7 +92,7 @@ String String::SubString(int start, int end) {
int String::IndexOf(const String& other, int index) {
- if(index < 0)
+ if (index < 0)
throw std::logic_error("Invalid index.\n");
int iter = 0;
@@ -159,10 +115,10 @@ int String::IndexOf(const char* str, int index) {
}
int String::CountOcurences(String str)
-{
+{
int count = 0;
- int i = IndexOf(str,0);
- while (i!=-1)
+ int i = IndexOf(str, 0);
+ while (i != -1)
{
count++;
i = IndexOf(str, i + 1);
@@ -186,7 +142,7 @@ inline int String::GetOcurence(String str, int num)
const char& String::operator[](int index) const {
- if(index >= len)
+ if (index >= len)
throw std::out_of_range("Out of range!");
return str[index];
}
@@ -236,5 +192,3 @@ const String operator+(const String& lhs, const String& rhs) {
return lhs;
return String(lhs) += rhs;
}
-
-#endif // !STRING_HDR
diff --git a/Classes/String/String.h b/Classes/String/String.h
new file mode 100644
index 0000000..37bbc6d
--- /dev/null
+++ b/Classes/String/String.h
@@ -0,0 +1,45 @@
+#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/Classes/Triangle/Triangle.hpp b/Classes/Triangle/Triangle.hpp
deleted file mode 100644
index ab0a8ff..0000000
--- a/Classes/Triangle/Triangle.hpp
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "point.hpp"
-
-class Triangle
-{
-public:
- Point p1;
- Point p2;
- Point p3;
- //Кой конструктор е по-добре да ползваме и защо?
- Triangle(Point p1, Point p2, Point p3);
- Triangle(int x1,int y1,int x2,int y2,int x3,int y3);
-
- double getPer();
-
-
-};
-Triangle::Triangle(Point p1, Point p2, Point p3)
-{
- this->p1 = p1;
- this->p2 = p2;
- this->p3 = p3;
-}
-Triangle::Triangle(int x1,int y1,int x2,int y2,int x3,int y3)
-{
- p1.x = x1;
- p1.y = y1;
- p2.x = x2;
- p2.y = y2;
- p3.x = x3;
- p3.y = y3;
-}
-// Използваме вече дефинираните функции, без да се интересуваме от тяхната реализация
-double Triangle::getPer()
-{
- return p1.DistTo(p2) + p2.DistTo(p3) + p3.DistTo(p1);
-}
diff --git a/Classes/Triangle/point.hpp b/Classes/Triangle/point.hpp
deleted file mode 100644
index a8a2c19..0000000
--- a/Classes/Triangle/point.hpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <iostream>
-
-struct Point
-{
- Point()
- {
- x = 0;
- y = 0;
- }
- Point(int x, int y)
- {
- this->x = x;
- this->y = y;
- }
- double DistTo(const Point& other)
- {
- int dx = x - other.x;
- int dy = y - other.y;
- return sqrt(dx*dx + dy*dy);
- }
- int x;
- int y;
-}; \ No newline at end of file
diff --git a/DiamondProblemAndPolymorphism/Chess/Bishop.hpp b/Diamond_problem_and_polymorphism/Chess/Bishop.hpp
index b46e315..014eb48 100644
--- a/DiamondProblemAndPolymorphism/Chess/Bishop.hpp
+++ b/Diamond_problem_and_polymorphism/Chess/Bishop.hpp
@@ -1,34 +1,34 @@
-#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';
+#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/DiamondProblemAndPolymorphism/Chess/Board.hpp b/Diamond_problem_and_polymorphism/Chess/Board.hpp
index 9ea5b93..95c0f41 100644
--- a/DiamondProblemAndPolymorphism/Chess/Board.hpp
+++ b/Diamond_problem_and_polymorphism/Chess/Board.hpp
@@ -1,127 +1,127 @@
-#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;
+#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/DiamondProblemAndPolymorphism/Chess/Figure.hpp b/Diamond_problem_and_polymorphism/Chess/Figure.hpp
index 2d3e73e..e3fa89d 100644
--- a/DiamondProblemAndPolymorphism/Chess/Figure.hpp
+++ b/Diamond_problem_and_polymorphism/Chess/Figure.hpp
@@ -1,35 +1,35 @@
-#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";
+#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/DiamondProblemAndPolymorphism/Chess/Knight.hpp b/Diamond_problem_and_polymorphism/Chess/Knight.hpp
index 90f93e9..01b9c34 100644
--- a/DiamondProblemAndPolymorphism/Chess/Knight.hpp
+++ b/Diamond_problem_and_polymorphism/Chess/Knight.hpp
@@ -1,38 +1,38 @@
-#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';
+#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/DiamondProblemAndPolymorphism/Chess/Queen.hpp b/Diamond_problem_and_polymorphism/Chess/Queen.hpp
index ad1add4..2f89029 100644
--- a/DiamondProblemAndPolymorphism/Chess/Queen.hpp
+++ b/Diamond_problem_and_polymorphism/Chess/Queen.hpp
@@ -1,25 +1,25 @@
-#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); //Ако не си успял като топ, пробвай като офицер.
-}
+#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/DiamondProblemAndPolymorphism/Chess/README.md b/Diamond_problem_and_polymorphism/Chess/README.md
index 97ee907..97ee907 100644
--- a/DiamondProblemAndPolymorphism/Chess/README.md
+++ b/Diamond_problem_and_polymorphism/Chess/README.md
diff --git a/DiamondProblemAndPolymorphism/Chess/Rook.hpp b/Diamond_problem_and_polymorphism/Chess/Rook.hpp
index d973870..5ad81c8 100644
--- a/DiamondProblemAndPolymorphism/Chess/Rook.hpp
+++ b/Diamond_problem_and_polymorphism/Chess/Rook.hpp
@@ -1,31 +1,31 @@
-#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';
+#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/DiamondProblemAndPolymorphism/Chess/main.cpp b/Diamond_problem_and_polymorphism/Chess/main.cpp
index 2caaee8..2caaee8 100644
--- a/DiamondProblemAndPolymorphism/Chess/main.cpp
+++ b/Diamond_problem_and_polymorphism/Chess/main.cpp
diff --git a/DiamondProblemAndPolymorphism/sd b/Diamond_problem_and_polymorphism/sd
index 6e9f0da..6e9f0da 100644
--- a/DiamondProblemAndPolymorphism/sd
+++ b/Diamond_problem_and_polymorphism/sd
diff --git a/GetAndSet/Beer.hpp b/GetAndSet/Beer.hpp
deleted file mode 100644
index ef0ed4b..0000000
--- a/GetAndSet/Beer.hpp
+++ /dev/null
@@ -1,74 +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;
-};
-
-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;
-}
-
-
-int main()
-{
- Beer t("Zagorka", 5); // 5 е невалидно количество бира. Но в конструктора извикваме setML, която се грижи в променливата да не попаднат невалидни данни.
- t.setMl(330);
- t.printBeer();
-}
diff --git a/Getters_and_setter_simple_examples/Beer/Beer.cpp b/Getters_and_setter_simple_examples/Beer/Beer.cpp
new file mode 100644
index 0000000..2eaa444
--- /dev/null
+++ b/Getters_and_setter_simple_examples/Beer/Beer.cpp
@@ -0,0 +1,43 @@
+#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_setter_simple_examples/Beer/Beer.h b/Getters_and_setter_simple_examples/Beer/Beer.h
new file mode 100644
index 0000000..4bc8adc
--- /dev/null
+++ b/Getters_and_setter_simple_examples/Beer/Beer.h
@@ -0,0 +1,27 @@
+#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_setter_simple_examples/Beer/main.cpp b/Getters_and_setter_simple_examples/Beer/main.cpp
new file mode 100644
index 0000000..9e6801d
--- /dev/null
+++ b/Getters_and_setter_simple_examples/Beer/main.cpp
@@ -0,0 +1,8 @@
+#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_setter_simple_examples/Daily_schedule/Event.cpp b/Getters_and_setter_simple_examples/Daily_schedule/Event.cpp
new file mode 100644
index 0000000..084c7b3
--- /dev/null
+++ b/Getters_and_setter_simple_examples/Daily_schedule/Event.cpp
@@ -0,0 +1,40 @@
+#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_setter_simple_examples/Daily_schedule/Event.h b/Getters_and_setter_simple_examples/Daily_schedule/Event.h
new file mode 100644
index 0000000..32c332d
--- /dev/null
+++ b/Getters_and_setter_simple_examples/Daily_schedule/Event.h
@@ -0,0 +1,19 @@
+#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_setter_simple_examples/Daily_schedule/Schedule.cpp b/Getters_and_setter_simple_examples/Daily_schedule/Schedule.cpp
new file mode 100644
index 0000000..b4c9017
--- /dev/null
+++ b/Getters_and_setter_simple_examples/Daily_schedule/Schedule.cpp
@@ -0,0 +1,62 @@
+#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_setter_simple_examples/Daily_schedule/Schedule.h b/Getters_and_setter_simple_examples/Daily_schedule/Schedule.h
new file mode 100644
index 0000000..2ad2c7a
--- /dev/null
+++ b/Getters_and_setter_simple_examples/Daily_schedule/Schedule.h
@@ -0,0 +1,19 @@
+#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_setter_simple_examples/Daily_schedule/Source.cpp b/Getters_and_setter_simple_examples/Daily_schedule/Source.cpp
new file mode 100644
index 0000000..678eb98
--- /dev/null
+++ b/Getters_and_setter_simple_examples/Daily_schedule/Source.cpp
@@ -0,0 +1,37 @@
+#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_setter_simple_examples/Daily_schedule/Time.cpp b/Getters_and_setter_simple_examples/Daily_schedule/Time.cpp
new file mode 100644
index 0000000..f4fc702
--- /dev/null
+++ b/Getters_and_setter_simple_examples/Daily_schedule/Time.cpp
@@ -0,0 +1,73 @@
+#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_setter_simple_examples/Daily_schedule/Time.h b/Getters_and_setter_simple_examples/Daily_schedule/Time.h
new file mode 100644
index 0000000..97529e0
--- /dev/null
+++ b/Getters_and_setter_simple_examples/Daily_schedule/Time.h
@@ -0,0 +1,21 @@
+#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/Homeworks/Homework_1.pdf b/Homework_tasks/Homework_1.pdf
index 8383550..8383550 100644
--- a/Homeworks/Homework_1.pdf
+++ b/Homework_tasks/Homework_1.pdf
Binary files differ
diff --git a/Homeworks/Homework_2.pdf b/Homework_tasks/Homework_2.pdf
index d36ee1b..d36ee1b 100644
--- a/Homeworks/Homework_2.pdf
+++ b/Homework_tasks/Homework_2.pdf
Binary files differ
diff --git a/OperatorOverloading/Complex/Complex.hpp b/Operator_overloading/Complex/Complex.hpp
index 8a6edd5..8a6edd5 100644
--- a/OperatorOverloading/Complex/Complex.hpp
+++ b/Operator_overloading/Complex/Complex.hpp
diff --git a/OperatorOverloading/Vector/Source.cpp b/Operator_overloading/Vector/Source.cpp
index 02b3dd5..c2e3c70 100644
--- a/OperatorOverloading/Vector/Source.cpp
+++ b/Operator_overloading/Vector/Source.cpp
@@ -1,14 +1,14 @@
-#include <iostream>
-#include "Vector.h"
-int main()
-{
-
-
- Vector v1(2);
-
- std::cin >> v1;
-
- std::cout << (v1);
-
-
-}
+#include <iostream>
+#include "Vector.h"
+int main()
+{
+
+
+ Vector v1(2);
+
+ std::cin >> v1;
+
+ std::cout << (v1);
+
+
+}
diff --git a/OperatorOverloading/Vector/Vector.cpp b/Operator_overloading/Vector/Vector.cpp
index 397cd46..5059a66 100644
--- a/OperatorOverloading/Vector/Vector.cpp
+++ b/Operator_overloading/Vector/Vector.cpp
@@ -1,145 +1,145 @@
-#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;
-}
+#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/OperatorOverloading/Vector/Vector.h b/Operator_overloading/Vector/Vector.h
index 03969d8..b8dbd20 100644
--- a/OperatorOverloading/Vector/Vector.h
+++ b/Operator_overloading/Vector/Vector.h
@@ -1,37 +1,37 @@
-#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); // Дали два вектора са перпендикулярни
+#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/Templates/Queue.hpp b/Templates/Queue/Queue.hpp
index 128f1df..128f1df 100644
--- a/Templates/Queue.hpp
+++ b/Templates/Queue/Queue.hpp
diff --git a/Templates/main.cpp b/Templates/Queue/main.cpp
index 89b8468..89b8468 100644
--- a/Templates/main.cpp
+++ b/Templates/Queue/main.cpp
diff --git a/Templates/test.txt b/Templates/test.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Templates/test.txt