From 969e4465100cc24748f9cd9797beee8e17385f5e Mon Sep 17 00:00:00 2001 From: San Jacobs Date: Sat, 6 Aug 2022 11:55:29 +0200 Subject: Removed std::vector usage, started windows stuff --- src/main.cpp | 36 +++++++++++++++++++----------------- src/time.h | 2 +- 2 files changed, 20 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 72e4df0..732d67a 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,7 +22,11 @@ along with this program. If not, see https://www.gnu.org/licenses/ #include "time.h" #include "test.h" -#define CLEAR "\033[2J\033[1;1H"; +#ifdef WIN32 + #define CLEAR std::system("cls") +#else + #define CLEAR std::cout << "\033[2J\033[1;1H" +#endif int main(int argc, char* argv[]) { @@ -54,7 +58,7 @@ int main(int argc, char* argv[]) long double social_costs = 1.26; while(1) { - std::cout << CLEAR; + CLEAR; std::cout << "\n------------- Setup and defaults -------------\n"; std::cout << "[d] Dayrate: " << dayrate << " (" << hourly_rate << " hourly)\n"; std::cout << "[w] Workdays to input: " << number_of_days << "\n"; @@ -102,10 +106,10 @@ int main(int argc, char* argv[]) } } setup_done: - std::cout << CLEAR; + CLEAR; //number_of_days = 1; // Just here for debugging - std::vector workdays; + workday workdays[number_of_days]; moment previous_wrap{0, 16, 20, 11, 1000}; // Set to a long time ago @@ -123,7 +127,7 @@ setup_done: moment lunch_end = lunch_start+(delta){30,0,0}; while(1) { - std::cout << CLEAR; + CLEAR; std::cout << "\n------------- DAY " << day+1 << " -------------\n"; std::cout << "[c] Calltime: " << timeprint(calltime) << "\n"; std::cout << "[w] Wraptime: " << timeprint(wraptime) << "\n"; @@ -166,28 +170,26 @@ setup_done: } done: - workdays.push_back({previous_wrap, + workdays[day] = {previous_wrap, calltime, wraptime, - planned_wraptime}); + planned_wraptime}; if(lunch_start != lunch_end) workdays[day].lunch(lunch_start, lunch_end); - workday* current_workday = &workdays[day]; + std::cout << "\nCalltime: " << timeprint(workdays[day].call) << "\n"; + std::cout << "Wraptime: " << timeprint(workdays[day].wrap) << "\n"; + std::cout << "Planned wrap: " << timeprint(workdays[day].planned_wrap) << "\n\n"; - std::cout << "\nCalltime: " << timeprint(current_workday->call) << "\n"; - std::cout << "Wraptime: " << timeprint(current_workday->wrap) << "\n"; - std::cout << "Planned wrap: " << timeprint(current_workday->planned_wrap) << "\n\n"; - - for(int i=0; itotal_timeblocks; i++) { - std::cout << "Timeblock " << i << ": " << timeprint(current_workday->blocks[i]) - << ". Total hours: " << current_workday->blocks[i].hourcount() - << "\t Valuefactor: " << current_workday->blocks[i].valuefactor << std::endl; + for(int i=0; i #include #include -#include #include enum weekday{ @@ -79,6 +78,7 @@ struct workday{ const moment& calltime, const moment& wraptime, const moment& planned_wraptime); + workday(){}; void lunch(const moment& lunch_start, const moment& lunch_end); }; -- cgit v1.2.1