aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSan Jacobs2022-08-06 11:55:29 +0200
committerSan Jacobs2022-08-06 11:55:29 +0200
commit969e4465100cc24748f9cd9797beee8e17385f5e (patch)
tree519e99a1f7dad30cea02f62b1f8282104b3b6d9e
parent3abe17c2e2a408cc43cbdd0f877a4416b51e3ae4 (diff)
downloadsatscalc-969e4465100cc24748f9cd9797beee8e17385f5e.tar.gz
satscalc-969e4465100cc24748f9cd9797beee8e17385f5e.tar.bz2
satscalc-969e4465100cc24748f9cd9797beee8e17385f5e.zip
Removed std::vector usage, started windows stuff
-rwxr-xr-xsrc/main.cpp36
-rwxr-xr-xsrc/time.h2
2 files changed, 20 insertions, 18 deletions
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<workday> 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; i<current_workday->total_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<workdays[day].total_timeblocks; i++) {
+ std::cout << "Timeblock " << i << ": " << timeprint(workdays[day].blocks[i])
+ << ". Total hours: " << workdays[day].blocks[i].hourcount()
+ << "\t Valuefactor: " << workdays[day].blocks[i].valuefactor << std::endl;
}
// This assumes that the user is entering things chronologically, which they may not be
previous_wrap = wraptime;
- std::cout << CLEAR;
+ CLEAR;
}
std::cout << "\n\n\n -+-+-+-+-+-+-+- CALCULATION -+-+-+-+-+-+-+-\n\n";
std::cout << "Dayrate: " << dayrate << "\n";
diff --git a/src/time.h b/src/time.h
index 6511213..637b111 100755
--- a/src/time.h
+++ b/src/time.h
@@ -4,7 +4,6 @@
#include <ios>
#include <iomanip>
#include <string.h>
-#include <vector>
#include <algorithm>
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);
};