diff options
clean up
13 files changed, 0 insertions, 277 deletions
| -rw-r--r-- | Utills/si_14.06/task2/Source.cpp | 14 | ||||
| -rw-r--r-- | Utills/si_14.06/task2/ValueArray/ValueArray.cpp | 72 | ||||
| -rw-r--r-- | Utills/si_14.06/task2/ValueArray/ValueArray.h | 26 | ||||
| -rw-r--r-- | Utills/si_14.06/task2/Values/Date/Date.cpp | 19 | ||||
| -rw-r--r-- | Utills/si_14.06/task2/Values/Date/Date.h | 22 | ||||
| -rw-r--r-- | Utills/si_14.06/task2/Values/DateTime/DateTime.cpp | 14 | ||||
| -rw-r--r-- | Utills/si_14.06/task2/Values/DateTime/DateTime.h | 14 | ||||
| -rw-r--r-- | Utills/si_14.06/task2/Values/String/StringValue.cpp | 14 | ||||
| -rw-r--r-- | Utills/si_14.06/task2/Values/String/StringValue.h | 15 | ||||
| -rw-r--r-- | Utills/si_14.06/task2/Values/Time/Time.cpp | 19 | ||||
| -rw-r--r-- | Utills/si_14.06/task2/Values/Time/Time.h | 19 | ||||
| -rw-r--r-- | Utills/si_14.06/task2/Values/ValueBase/Value.cpp | 11 | ||||
| -rw-r--r-- | Utills/si_14.06/task2/Values/ValueBase/Value.h | 18 |
diff --git a/Utills/si_14.06/task2/Source.cpp b/Utills/si_14.06/task2/Source.cpp deleted file mode 100644 index e8e1a2d..0000000 --- a/Utills/si_14.06/task2/Source.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include <iostream> -#include "ValueArray/ValueArray.h" - -int main() -{ - ValueArray v; - - v.addDate("First school day",15, 9, 2021); - v.addTime("Work day start", 10, 15); - v.addDateTime("Portugal - Germany", 19, 06, 2021, 19, 10); - v.addString("Name", "Test"); - - v.print(); -}
\ No newline at end of file diff --git a/Utills/si_14.06/task2/ValueArray/ValueArray.cpp b/Utills/si_14.06/task2/ValueArray/ValueArray.cpp deleted file mode 100644 index 8e06a95..0000000 --- a/Utills/si_14.06/task2/ValueArray/ValueArray.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include <iostream> -#include "ValueArray.h" -#include "../Values/Date/Date.h" -#include "../Values/Time/Time.h" -#include "../Values/String/StringValue.h" -#include "../Values/DateTime/DateTime.h" - -void ValueArray::print() const -{ - std::cout << "["; - for (int i = 0; i < arr.size(); i++) - { - std::cout << arr[i]->toString(); - - if (i != arr.size() - 1) - std::cout << ", "; - - } - std::cout << "]"; -} - - -void ValueArray::free() -{ - for (int i = 0; i < arr.size(); i++) - delete arr[i]; - arr.clear(); -} - -void ValueArray::copyFrom(const ValueArray& other) -{ - arr.resize(other.arr.size()); - - for (int i = 0; i < arr.size(); i++) - arr[i] = other.arr[i]->clone(); -} - -void ValueArray::addDate(const std::string& name, unsigned day, unsigned month, unsigned year) -{ - arr.push_back(new Date(name, day, month, year)); -} -void ValueArray::addTime(const std::string& name, unsigned hours, unsigned mins) -{ - arr.push_back(new Time(name, hours, mins)); -} -void ValueArray::addString(const std::string& name, const std::string& value) -{ - arr.push_back(new StringValue(name,value)); -} -void ValueArray::addDateTime(const std::string& name, unsigned day, unsigned month, unsigned year, unsigned hours, unsigned mins) -{ - arr.push_back(new DateTime(name, day, month, year, hours, mins)); -} - -ValueArray::ValueArray(const ValueArray& other) -{ - copyFrom(other); -} -ValueArray& ValueArray::operator= (const ValueArray& other) -{ - if (this != &other) - { - free(); - copyFrom(other); - } - return *this; -} - -ValueArray::~ValueArray() -{ - free(); -}
\ No newline at end of file diff --git a/Utills/si_14.06/task2/ValueArray/ValueArray.h b/Utills/si_14.06/task2/ValueArray/ValueArray.h deleted file mode 100644 index 39bdcbc..0000000 --- a/Utills/si_14.06/task2/ValueArray/ValueArray.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include <vector> -#include "../Values/ValueBase/Value.h" - -class ValueArray -{ - std::vector<Value*> arr; - - void copyFrom(const ValueArray& other); - void free(); - -public: - void print() const; - - ValueArray() = default; - ValueArray(const ValueArray& other); - ValueArray& operator=(const ValueArray& other); - - //factory pattern ? - void addDate(const std::string& name, unsigned day, unsigned month, unsigned year); - void addTime(const std::string& name, unsigned hours, unsigned mins); - void addString(const std::string& name, const std::string& value); - void addDateTime(const std::string& name, unsigned day, unsigned month, unsigned year, unsigned hours, unsigned mins); - ~ValueArray(); -};
\ No newline at end of file diff --git a/Utills/si_14.06/task2/Values/Date/Date.cpp b/Utills/si_14.06/task2/Values/Date/Date.cpp deleted file mode 100644 index 3d872d3..0000000 --- a/Utills/si_14.06/task2/Values/Date/Date.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "Date.h" - -//validation is needed for the date fields! -Date::Date(const std::string& name, unsigned day, unsigned month, unsigned year) : Value(name), year(year), month(month), day(day) -{} - -std::string Date::getDateString() const -{ - return std::to_string(day) + "." + std::to_string(month) + "." + std::to_string(year);; -} -std::string Date::toString() const -{ - return getPrefix() + getDateString() + "}"; -} - -Value* Date::clone() const -{ - return new Date(*this); -}
\ No newline at end of file diff --git a/Utills/si_14.06/task2/Values/Date/Date.h b/Utills/si_14.06/task2/Values/Date/Date.h deleted file mode 100644 index 6194225..0000000 --- a/Utills/si_14.06/task2/Values/Date/Date.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include "../ValueBase/Value.h" - -class Date : public virtual Value -{ - unsigned day; - unsigned month; - unsigned year; - -protected: - - std::string getDateString() const; - -public: - - Date(const std::string& name, unsigned day, unsigned month, unsigned year); - - Value* clone() const; - - std::string toString() const; -};
\ No newline at end of file diff --git a/Utills/si_14.06/task2/Values/DateTime/DateTime.cpp b/Utills/si_14.06/task2/Values/DateTime/DateTime.cpp deleted file mode 100644 index b2e7e97..0000000 --- a/Utills/si_14.06/task2/Values/DateTime/DateTime.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "DateTime.h" - -DateTime::DateTime(const std::string& name, size_t day, size_t month, size_t year, size_t hours, size_t mins) : Value(name), Date(name, day, month, year), Time(name, hours,mins) -{} - -std::string DateTime::toString() const -{ - return getPrefix() + getDateString() + ", " + getTimeString() + "}"; -} - -Value* DateTime::clone() const -{ - return new DateTime(*this); -}
\ No newline at end of file diff --git a/Utills/si_14.06/task2/Values/DateTime/DateTime.h b/Utills/si_14.06/task2/Values/DateTime/DateTime.h deleted file mode 100644 index 61d6a9a..0000000 --- a/Utills/si_14.06/task2/Values/DateTime/DateTime.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "../Date/Date.h" -#include "../Time/Time.h" - -class DateTime : public Date, public Time -{ -public: - DateTime(const std::string& name, size_t day, size_t month, size_t year, size_t hours, size_t mins); - - std::string toString() const; - - Value* clone() const; -};
\ No newline at end of file diff --git a/Utills/si_14.06/task2/Values/String/StringValue.cpp b/Utills/si_14.06/task2/Values/String/StringValue.cpp deleted file mode 100644 index 8d47f24..0000000 --- a/Utills/si_14.06/task2/Values/String/StringValue.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "StringValue.h" - -StringValue::StringValue(const std::string& name, const std::string& value) : Value(name), value(value) -{} - -std::string StringValue::toString() const -{ - return getPrefix() + '\"' + value + '\"' + "}"; -} - -Value* StringValue::clone() const -{ - return new StringValue(*this); -}
\ No newline at end of file diff --git a/Utills/si_14.06/task2/Values/String/StringValue.h b/Utills/si_14.06/task2/Values/String/StringValue.h deleted file mode 100644 index 4e1500f..0000000 --- a/Utills/si_14.06/task2/Values/String/StringValue.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "../ValueBase/Value.h" - -class StringValue : public Value -{ - std::string value; -public: - - StringValue(const std::string& name, const std::string& value); - - Value* clone() const; - - std::string toString() const; -};
\ No newline at end of file diff --git a/Utills/si_14.06/task2/Values/Time/Time.cpp b/Utills/si_14.06/task2/Values/Time/Time.cpp deleted file mode 100644 index 5b49e54..0000000 --- a/Utills/si_14.06/task2/Values/Time/Time.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "Time.h" - -//validation is needed for the time fields! -Time::Time(const std::string& name, unsigned hours, unsigned mins) : Value(name), hours(hours), mins(mins) -{} - -std::string Time::getTimeString() const -{ - return std::to_string(hours) + ":" + std::to_string(mins); -} -std::string Time::toString() const -{ - return getPrefix() + getTimeString() + "}"; -} - -Value* Time::clone() const -{ - return new Time(*this); -}
\ No newline at end of file diff --git a/Utills/si_14.06/task2/Values/Time/Time.h b/Utills/si_14.06/task2/Values/Time/Time.h deleted file mode 100644 index 1d93d49..0000000 --- a/Utills/si_14.06/task2/Values/Time/Time.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "../ValueBase/Value.h" - -class Time : public virtual Value -{ - unsigned hours; - unsigned mins; - -protected: - std::string Time::getTimeString() const; - -public: - Time(const std::string& name, unsigned hours, unsigned mins); - - Value* clone() const; - - std::string toString() const; -};
\ No newline at end of file diff --git a/Utills/si_14.06/task2/Values/ValueBase/Value.cpp b/Utills/si_14.06/task2/Values/ValueBase/Value.cpp deleted file mode 100644 index cd7c821..0000000 --- a/Utills/si_14.06/task2/Values/ValueBase/Value.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "Value.h" - -Value::Value(const std::string& valueName) : valueName(valueName) -{ - -} - -std::string Value::getPrefix() const -{ - return "{ " + valueName + " : "; -}
\ No newline at end of file diff --git a/Utills/si_14.06/task2/Values/ValueBase/Value.h b/Utills/si_14.06/task2/Values/ValueBase/Value.h deleted file mode 100644 index e3320f3..0000000 --- a/Utills/si_14.06/task2/Values/ValueBase/Value.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include <string> - -class Value -{ -protected: - std::string valueName; -public: - Value(const std::string& valueName); - - std::string getPrefix() const; - - virtual std::string toString() const = 0; - - virtual Value* clone() const = 0; - - virtual ~Value(){} -};
\ No newline at end of file |
