From c53d9c63bf942963739ec97922b380108b8e9768 Mon Sep 17 00:00:00 2001 From: PolishPigeon <76916461+PolishPigeon@users.noreply.github.com> Date: Sun, 3 Jan 2021 19:39:10 +0100 Subject: [PATCH] Adding all of project base files --- allFunctions.hpp | 73 ++++++++++++++++ basic.cpp | 209 +++++++++++++++++++++++++++++++++++++++++++++ check.cpp | 180 ++++++++++++++++++++++++++++++++++++++ constants.hpp | 126 +++++++++++++++++++++++++++ dataStructures.hpp | 44 ++++++++++ file.cpp | 92 ++++++++++++++++++++ getters.cpp | 137 +++++++++++++++++++++++++++++ input.cpp | 105 +++++++++++++++++++++++ main.cpp | 32 +++++++ output.cpp | 163 +++++++++++++++++++++++++++++++++++ valid.cpp | 63 ++++++++++++++ 11 files changed, 1224 insertions(+) create mode 100644 allFunctions.hpp create mode 100644 basic.cpp create mode 100644 check.cpp create mode 100644 constants.hpp create mode 100644 dataStructures.hpp create mode 100644 file.cpp create mode 100644 getters.cpp create mode 100644 input.cpp create mode 100644 main.cpp create mode 100644 output.cpp create mode 100644 valid.cpp diff --git a/allFunctions.hpp b/allFunctions.hpp new file mode 100644 index 0000000..76f27ab --- /dev/null +++ b/allFunctions.hpp @@ -0,0 +1,73 @@ +#ifndef ALL_FUNCTIONS_HPP +#define ALL_FUNCTIONS_HPP + +#include +#include "dataStructures.hpp" +#include "constants.hpp" + +//basic.cpp +int charToInt(const char c); +void print(const std::string s); +bool charIsNumber(const char c); +int getDaysFromMonth(const monthChecker month); +void printOneStringColor(const std::vector vector, const int oneTask); +void printDate(const Date date); +void printErrorStringContainsNotNumber(const std::string s); +void printNumberTooLow(const int number, const int min); +void printNumberTooHigh(const int number, const int max); +void printNotValidStringLength(const std::string s, const int desiredLength); +void printInvalidCharacter(const char c, const char desiredCharacter); +bool numberTooLow(const int number, const int min); +bool numberTooHigh(const int number, const int max); +void printStringVector(const std::vector vector); + +//check.cpp +bool checkLongerMonth(const int month); +bool checkMenu(const std::string input); +bool checkTitle(const std::string title); +bool checkTime(const std::string time); +bool checkLeap(const int year); +bool checkDate(const std::string date); +bool taskForToday(const Date dateFromFile); +bool checkRepeat(const std::string input); +bool checkWhenRepeat(const std::string whenRepeat); + +//file.cpp +void fileAddTask(const Task taskToAdd); +std::vector readList(); +std::vector getTitles(const std::vector fileLines); +std::vector getTimes(const std::vector fileLines); +std::vector getDates(const std::vector fileLines); +void fileReadToday(); +std::vector removeCompleted(const std::vector fileList, + const std::vector tasksToday); + +void outputFile(const std::vector fileLines); + +//getters.cpp +std::vector getDate(const std::vector dividedTasks); +std::vector getDividedTasks(const std::vector fileLines); +std::vector getTasksToday(const std::vector dividedTasks); + +//void fileAddRepeatingTask(const repeatTask taskToAdd); + +//input.cpp +std::string inputTaskOneLine(const int whatToCheck); +Task inputTask(); +int inputMenu(); +void continueProgram(const int &userChoice); +bool menuLoop(); + +//output.cpp +void checkToday(); + +//valid.cpp +bool validString(const std::string s); +bool validNumberInput(const std::string input, const int min, const int max); +bool validStringLength(const std::string s, const int desiredLength); +bool validCharacter(const char inputC, const char desiredC); +bool validAddTaskInput(const std::string input, const int inputType); + + + +#endif \ No newline at end of file diff --git a/basic.cpp b/basic.cpp new file mode 100644 index 0000000..247e8e1 --- /dev/null +++ b/basic.cpp @@ -0,0 +1,209 @@ +#ifndef BASIC_CPP +#define BASIC_CPP + +#include +#include +#include +#include +#include "dataStructures.hpp" +#include "constants.hpp" + +void print(const std::string s) { std::cout << s << std::endl; } +int charToInt(const char c) { return c - '0'; } + +void e() { print("Poor man breakboint"); } + +bool charIsNumber(const char c) { return c >= '0' && c <= '9'; } + + +void printErrorStringContainsNotNumber(const std::string s) +{ + std::cout << "string: \"" << s + << "\" contains character different than number " << std::endl; +} + +void printNumberTooLow(const int number, const int min) +{ + std::cout << "number: " << number + << " is too low. Minimal number is: " << min << std::endl; +} + +void printNumberTooHigh(const int number, const int max) +{ + std::cout << "number: " << number + << " is too high. Maximal number is: " << max << std::endl; +} + +void printNotValidStringLength(const std::string s, const int desiredLength) +{ + std::cout << "String: \"" << s << "\" is too short/too long, it is: " + << s.length() << " characters long but should be: " << desiredLength + << " characters long " << std::endl; +} + +void printInvalidCharacter(const char c, const char desiredCharacter) +{ + std::cout << "[ " << c << " ] Is invalid character, expected: [ " + << desiredCharacter << " ]" << std::endl; +} + +void printContainsIllegalCharacter( const std::string s, + const char illegalCharacter ) +{ + std::cout << "String: " << s << " consists of illegal sign: [" + << illegalCharacter << "]!" << std::endl; +} + + +bool numberTooLow(const int number, const int min) +{ + if(number < min) + { + printNumberTooLow(number, min); + return 1; + } + return 0; +} + +bool numberTooHigh(const int number, const int max) +{ + if(number > max) + { + printNumberTooHigh(number, max); + return 1; + } + return 0; +} + +bool containsIllegalCharacter(const std::string s, const char illegalCharacter) +{ + if( s.find(illegalCharacter) != std::string::npos) + { + printContainsIllegalCharacter(s, illegalCharacter); + return 1; + } + return 0; +} + +void printTaskVector(const std::vector vector) +{ + print("Printing titles"); + for(unsigned int i = 0; i < vector.size(); i++) print(vector.at(i).title); + //print("Printing times"); + //for(unsigned int i = 0; i < vector.size(); i++) print(vector.at(i).time); + print("Printing dates"); + for(unsigned int i = 0; i < vector.size(); i++) print(vector.at(i).date); +} + +/* +void printTimeVector(const std::vector