From 793100813b3c50a1f304904440366a7137ae0992 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Wed, 30 Mar 2022 08:41:52 +0300 Subject: Reworked yesterdays oop practice folder structure --- .../05-Practice-29.03.2022/ex1-Entity.cpp | 14 ------- .../05-Practice-29.03.2022/ex1-Entity.h | 13 ------ .../05-Practice-29.03.2022/ex1-Source.cpp | 8 ---- .../05-Practice-29.03.2022/ex2-Rational.cpp | 47 ---------------------- .../05-Practice-29.03.2022/ex2-Rational.h | 24 ----------- .../05-Practice-29.03.2022/ex2-Source.cpp | 17 -------- .../06-Practice-29.03.2022/ex1/Entity.cpp | 14 +++++++ .../06-Practice-29.03.2022/ex1/Entity.h | 13 ++++++ .../06-Practice-29.03.2022/ex1/Source.cpp | 8 ++++ .../06-Practice-29.03.2022/ex2/Rational.cpp | 47 ++++++++++++++++++++++ .../06-Practice-29.03.2022/ex2/Rational.h | 24 +++++++++++ .../06-Practice-29.03.2022/ex2/Source.cpp | 17 ++++++++ 12 files changed, 123 insertions(+), 123 deletions(-) delete mode 100644 Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex1-Entity.cpp delete mode 100644 Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex1-Entity.h delete mode 100644 Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex1-Source.cpp delete mode 100644 Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex2-Rational.cpp delete mode 100644 Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex2-Rational.h delete mode 100644 Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex2-Source.cpp create mode 100644 Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex1/Entity.cpp create mode 100644 Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex1/Entity.h create mode 100644 Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex1/Source.cpp create mode 100644 Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Rational.cpp create mode 100644 Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Rational.h create mode 100644 Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Source.cpp (limited to 'Year 1/Object-oriented Programming') diff --git a/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex1-Entity.cpp b/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex1-Entity.cpp deleted file mode 100644 index 0252a13..0000000 --- a/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex1-Entity.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "ex1-Entity.h" -#include - -Entity::Entity() { - x = 0; - std::cout << "Entity created!"; -} -Entity::Entity(int xVal) { - x = xVal; -} - -Entity::~Entity() { - std::cout << "Entity destroyed"; -} diff --git a/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex1-Entity.h b/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex1-Entity.h deleted file mode 100644 index 89c8d3f..0000000 --- a/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex1-Entity.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef ENTITY_HEADER -#define ENTITY_HEADER - -class Entity { -private: - int x; -public: - Entity(); - Entity(int xVal); - ~Entity(); -}; - -#endif // !ENTITY_HEADER diff --git a/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex1-Source.cpp b/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex1-Source.cpp deleted file mode 100644 index fbf5934..0000000 --- a/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex1-Source.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "ex1-Entity.h" - -int main() { - Entity f; - Entity s(10); - Entity* t = new Entity; - Entity x(); -} diff --git a/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex2-Rational.cpp b/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex2-Rational.cpp deleted file mode 100644 index 05794b5..0000000 --- a/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex2-Rational.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "ex2-Rational.h" - -Rational::Rational(int numerator, int denumerator) { - set_numerator(numerator); - set_denumerator(denumerator); -} - -int Rational::get_numerator() const { - return numerator; -} -void Rational::set_numerator(int numerator) { - this->numerator = numerator; -} - -int Rational::get_denumerator() const { - return denumerator; -} -void Rational::set_denumerator(int denumerator) { - this->denumerator = denumerator; -} - -void canonize() { - -} - -Rational Rational::operator+(const Rational& other) { - return Rational(numerator * other.denumerator + other.numerator * denumerator, denumerator * other.denumerator); -} - -//x a = x*b + y*a -//y b y*b - -Rational Rational::operator-(const Rational& other) { - return Rational(numerator * other.denumerator - other.numerator * denumerator, denumerator * other.denumerator); -} - -Rational Rational::operator*(const Rational& other) { - return Rational(numerator * other.numerator, denumerator * other.denumerator); -} - -Rational Rational::operator/(const Rational& other) { - return Rational(numerator / other.numerator, denumerator / other.denumerator); -} - -int Rational::numcmp(const Rational& arg) const { - -} diff --git a/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex2-Rational.h b/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex2-Rational.h deleted file mode 100644 index f95e520..0000000 --- a/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex2-Rational.h +++ /dev/null @@ -1,24 +0,0 @@ -class Rational { - int numerator; - int denumerator; - -public: - Rational(int numerator, int denumerator); - - int get_numerator() const; - void set_numerator(int numerator); - - int get_denumerator() const; - void set_denumerator(int denumerator); - - void canonize(); - - Rational operator+(const Rational& other); - Rational operator-(const Rational& other); - Rational operator*(const Rational& other); - Rational operator/(const Rational& other); - - int numcmp(const Rational& arg) const; - - void print() const; -}; diff --git a/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex2-Source.cpp b/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex2-Source.cpp deleted file mode 100644 index 906ce83..0000000 --- a/Year 1/Object-oriented Programming/05-Practice-29.03.2022/ex2-Source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "ex2-Rational.h" - -int main() { - -} -/* - -5 - 1 = 4 -5 / 1 = 5 - -5 - 9 = -4 -5 / 9 = 0... - -5 - 5 = 0 -5 / 5 = 1 - -*/ diff --git a/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex1/Entity.cpp b/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex1/Entity.cpp new file mode 100644 index 0000000..a4ad52e --- /dev/null +++ b/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex1/Entity.cpp @@ -0,0 +1,14 @@ +#include "Entity.h" +#include + +Entity::Entity() { + x = 0; + std::cout << "Entity created!"; +} +Entity::Entity(int xVal) { + x = xVal; +} + +Entity::~Entity() { + std::cout << "Entity destroyed"; +} diff --git a/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex1/Entity.h b/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex1/Entity.h new file mode 100644 index 0000000..89c8d3f --- /dev/null +++ b/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex1/Entity.h @@ -0,0 +1,13 @@ +#ifndef ENTITY_HEADER +#define ENTITY_HEADER + +class Entity { +private: + int x; +public: + Entity(); + Entity(int xVal); + ~Entity(); +}; + +#endif // !ENTITY_HEADER diff --git a/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex1/Source.cpp b/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex1/Source.cpp new file mode 100644 index 0000000..5dd73a8 --- /dev/null +++ b/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex1/Source.cpp @@ -0,0 +1,8 @@ +#include "Entity.h" + +int main() { + Entity f; + Entity s(10); + Entity* t = new Entity; + Entity x(); +} diff --git a/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Rational.cpp b/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Rational.cpp new file mode 100644 index 0000000..cc28545 --- /dev/null +++ b/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Rational.cpp @@ -0,0 +1,47 @@ +#include "Rational.h" + +Rational::Rational(int numerator, int denumerator) { + set_numerator(numerator); + set_denumerator(denumerator); +} + +int Rational::get_numerator() const { + return numerator; +} +void Rational::set_numerator(int numerator) { + this->numerator = numerator; +} + +int Rational::get_denumerator() const { + return denumerator; +} +void Rational::set_denumerator(int denumerator) { + this->denumerator = denumerator; +} + +void canonize() { + +} + +Rational Rational::operator+(const Rational& other) { + return Rational(numerator * other.denumerator + other.numerator * denumerator, denumerator * other.denumerator); +} + +//x a = x*b + y*a +//y b y*b + +Rational Rational::operator-(const Rational& other) { + return Rational(numerator * other.denumerator - other.numerator * denumerator, denumerator * other.denumerator); +} + +Rational Rational::operator*(const Rational& other) { + return Rational(numerator * other.numerator, denumerator * other.denumerator); +} + +Rational Rational::operator/(const Rational& other) { + return Rational(numerator / other.numerator, denumerator / other.denumerator); +} + +int Rational::numcmp(const Rational& arg) const { + +} diff --git a/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Rational.h b/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Rational.h new file mode 100644 index 0000000..f95e520 --- /dev/null +++ b/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Rational.h @@ -0,0 +1,24 @@ +class Rational { + int numerator; + int denumerator; + +public: + Rational(int numerator, int denumerator); + + int get_numerator() const; + void set_numerator(int numerator); + + int get_denumerator() const; + void set_denumerator(int denumerator); + + void canonize(); + + Rational operator+(const Rational& other); + Rational operator-(const Rational& other); + Rational operator*(const Rational& other); + Rational operator/(const Rational& other); + + int numcmp(const Rational& arg) const; + + void print() const; +}; diff --git a/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Source.cpp b/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Source.cpp new file mode 100644 index 0000000..149ff8e --- /dev/null +++ b/Year 1/Object-oriented Programming/06-Practice-29.03.2022/ex2/Source.cpp @@ -0,0 +1,17 @@ +#include "Rational.h" + +int main() { + +} +/* + +5 - 1 = 4 +5 / 1 = 5 + +5 - 9 = -4 +5 / 9 = 0... + +5 - 5 = 0 +5 / 5 = 1 + +*/ -- cgit v1.3.1-23-gd82d