-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTypingGame.cpp
81 lines (66 loc) · 1.95 KB
/
TypingGame.cpp
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
#include "includes.hpp"
// int random()
// {
// std::default_random_engine generator;
// std::uniform_int_distribution<int> dist(0, 29);
// return dist(generator);
// }
// int input(std::istream &input) // i think it's a good practise will ask about this.... but it will avoid unecessary permanent container in main funcition which can't deleted
// {
// int in;
// std ::input >> in; // see you learned -_- something new cuz idea always gives you new understanding
// return in;
// }
int input()
{
char n = getch();
return n;
}
int eval(std::vector<float> value)
{
float accuracy = float(value[2] - value[1]) / float(value[2]) * 100;
std ::cout << "Your Score : " << value[0] << std ::endl
<< "Acurracy : " << float(accuracy);
return value[2] - value[1];
}
int main()
{
std ::cout << "Press Enter To start : " << std ::endl;
std ::cout << "choose your options : " << std ::endl
<< "1 : Animal 2: CarNames 3:Cities " << std ::endl;
auto start_time = std::chrono::high_resolution_clock::now();
int count = 0;
switch (input())
{
case '1':
{
std ::vector<float> sc = score(AnimaNames);
system("CLS");
count = eval(sc); // Eval Scoress
break;
}
case '2':
{
system("CLS");
count = eval(score(CarNames));
break;
}
case '3':
{
system("CLS");
count = eval(score(CityNames));
break;
}
// default:
// {
// std ::cout << in << " Not found, enter again";
// goto lable;
// }
}
auto end_time = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::seconds>(end_time - start_time);
std::cout << std ::endl
<< "Total Time : " << duration.count() << "sec" << std ::endl;
std ::cout << "WPM : " << count * ((duration.count()) / 60);
return 0;
}