-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
75 lines (56 loc) · 1.48 KB
/
main.cpp
File metadata and controls
75 lines (56 loc) · 1.48 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
#include <iostream>
#include <limits>
#include <vector>
#include "icommand.h"
#include "appendtextcommand.h"
#include "commandstack.h"
#include "uppercasecommand.h"
using namespace std;
int main()
{
string teste;
string appendstr;
CommandStack stack;
int opcao;
while(true)
{
cout << teste << "\n\n\n"
<< "1 para concatenar uma string na string digitada\n"
<< "2 para deixar a string inteira maiuscula\n"
<< "3 para dar << undo no command atual\n"
<< "4 para dar redo >> no command atual\n"
<< "0 para sair\n";
cin >> opcao;
if(opcao == 1)
{
cout << "Digite uma string a ser concatenada: ";
// purging keyboard buffer
cin.clear();
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
getline(cin, appendstr);
if(appendstr.empty())
{
cout << "\n\nErro: Nada foi digitado\n\n";
continue;
}
stack.push(new AppendTextCommand(&teste, appendstr));
}
else if(opcao == 2)
{
stack.push(new UppercaseCommand(&teste));
}
else if(opcao == 3)
{
stack.undo();
}
else if(opcao == 4)
{
stack.redo();
}
else if(!opcao)
{
break;
}
} // while
return 0;
}