-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLog.h
More file actions
55 lines (40 loc) · 1.54 KB
/
Log.h
File metadata and controls
55 lines (40 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once
#pragma warning(disable : 4996) // To disable the deprecated error that show us when ctime function is used.
#include <iostream>
#include <fstream>
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <ctime>
void logCoffee(std::string coffeeNames[], double coffeePrices[], const long double coinsValue[], int coffeeCups[], int coinsAmount[], bool arrAllow[]) {
time_t rawDate = time(nullptr);// taking the time as second
std::string date = ctime(&rawDate);
std::ofstream dbW("dataBase.txt", std::ios_base::out);
dbW << date << "\n\n";
dbW << "~Coffee types~\n";
for (int i = 0; i < 5; i++)
dbW << " " << coffeeNames[i] << "\n";
dbW << "\n~Coffee prices~\n";
for (int i = 0; i < 5; i++)
dbW << " " << coffeeNames[i] << " -> " << coffeePrices[i] << " KM." << "\n";
dbW << "\n~Valid Coin Types~\n";
for (int i = 0; i < 7; i++)
if (arrAllow[i] == 1) {
dbW << " " << coinsValue[i] << " -> TRUE.\n";
}
else if (arrAllow[i] == 0) {
dbW << " " << coinsValue[i] << " -> FALSE.\n";
}
dbW << "\n~Number of each coffee~\n";
for (int i = 0; i < 5; i++)
dbW << " " << coffeeNames[i] << " -> " << coffeeCups[i] << '\n';
dbW << "\n~Coin amounts~\n";
double total = 0;
for (int i = 0; i < 7; i++) {
dbW << " " << coinsValue[i] << ": " << coinsAmount[i] << '\n';
total += coinsValue[i] * coinsAmount[i];
}
dbW << " " << "\n~Money Earned: "<< (total - 26.55) << " KM.";
dbW << " " << "\n~Total in Machine: " << total << " KM.\n\n" << " " << "\n\n~End of the Log file :)\n\n";
}