-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
56 lines (56 loc) · 1.14 KB
/
main.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
#include <iostream>
#include <string>
#include <unistd.h>
#include "commands/commands.cpp"
int main()
{
using namespace std;
string command;
while(1 == 1)
{
cout << "Command: ";
cin >> command;
if(command == "")
return 0;
if(command != "")
{
//Here declare command words.
if(command == "help")
help();
else if(command == "exit")
exitTerminal();
else if(command == "about")
about();
else if(command == "calculator" || command == "calc")
calculator();
else if(command == "version")
version();
else if(command == "timer" || command == "waitfor")
{
//This code must be moved in another file.
int time;
int currtime;
cin >> time;
if(cin.fail())
{
cout << "One of the numbers is invalid!" << endl;
cin.clear();
}
cout << "Timer started!" << endl;
while(currtime <= time)
{
sleep(1);
cout << currtime << endl;
if(currtime == time)
cout << time << " seconds passed!" <<endl;
currtime++;
}
currtime = 0;
}
else if(command == "credits")
credits();
else
cout << "Wrong command!" << endl; //If command is not declared.
}
}
}