-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLog.cpp
More file actions
102 lines (75 loc) · 2.29 KB
/
Log.cpp
File metadata and controls
102 lines (75 loc) · 2.29 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include<iostream>
#include<fstream>
#include<string>
#include <algorithm>
#include "Log.h"
void logCoffee(int coffeeCups[], int coinsAmmount[]){
time_t rawDate = time(nullptr);// taking the time as second
std::string date = ctime(&rawDate);
std::replace(date.begin(), date.end(), ' ','_');
std::replace(date.begin(), date.end(), ':','-');
std::replace(date.begin(), date.end(), '\n','.');
date += "txt";
//std::cout<< date <<"\n";
std::ofstream dbW(date,std::ios_base::out);
dbW<<"lefted Coffee:\n";
for(int i=0; i<5; i++){
switch (i){
case 0:
dbW<<"Latte: "<<coffeeCups[i]<<'\n';
//ctotal + = 1 * coffeeCups[i];
break;
case 1:
dbW<<"Capu: "<<coffeeCups[i]<<'\n';
break;
case 2:
dbW<<"Kafa: "<<coffeeCups[i]<<'\n';
break;
case 3:
dbW<<"Kahve: "<<coffeeCups[i]<<'\n';
break;
case 4:
dbW<<"Kola: "<<coffeeCups[i]<<'\n';
break;
default:
break;
}
}
dbW<<"\nCoin amounts:\n";
double total = 0;
for(int i=0; i<7; i++){
switch (i){
case 0:
dbW<<"0.5: "<<coinsAmmount[i]<<'\n';
total += 0.5*coinsAmmount[i];
break;
case 1:
dbW<<"0.1: "<<coinsAmmount[i]<<'\n';
total += 0.1*coinsAmmount[i];
break;
case 2:
dbW<<"0.2: "<<coinsAmmount[i]<<'\n';
total += 0.2*coinsAmmount[i];
break;
case 3:
dbW<<"1: "<<coinsAmmount[i]<<'\n';
total += 1*coinsAmmount[i];
break;
case 4:
dbW<<"5: "<<coinsAmmount[i]<<'\n';
total += 5*coinsAmmount[i];
break;
case 5:
dbW<<"10: "<<coinsAmmount[i]<<'\n';
total += 10*coinsAmmount[i];
break;
case 6:
dbW<<"20: "<<coinsAmmount[i]<<'\n';
total += 20*coinsAmmount[i];
break;
default:
break;
}
}
dbW<<"\nTotal: "<<total<<" KM.\n\nEnd of the File\n\n";
}