-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
113 lines (96 loc) · 2.7 KB
/
main.cpp
File metadata and controls
113 lines (96 loc) · 2.7 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
103
104
105
106
107
108
109
110
111
112
113
#include "Bureaucrat.hpp"
#include "AForm.hpp"
#include "print.hpp"
#include "PresidentialPardonForm.hpp"
#include "RobotomyRequestForm.hpp"
#include "ShrubberyCreationForm.hpp"
namespace Tests
{
void creation_grades()
{
PresidentialPardonForm pardon("pardon");
ShrubberyCreationForm tree("tree");
RobotomyRequestForm robot("robot");
print (CYAN SUB_TITTLE "Shrubbery\n" RESET);
print ("Sign grade: " << tree.getSignGrade());
print ("Exec grade: " << tree.getExecGrade());
print ("Target: " << tree.getTarget());
print ("Name: " << tree.getName());
print (CYAN SUB_TITTLE "Robotomy\n" RESET);
print ("Sign grade: " << robot.getSignGrade());
print ("Exec grade: " << robot.getExecGrade());
print ("Target: " << robot.getTarget());
print ("Name: " << robot.getName());
print (CYAN SUB_TITTLE "Presidential\n" RESET);
print ("Sign grade: " << pardon.getSignGrade());
print ("Exec grade: " << pardon.getExecGrade());
print ("Target: " << pardon.getTarget());
print ("Name: " << pardon.getName());
}
void form_actions()
{
PresidentialPardonForm pardon("pardon");
ShrubberyCreationForm tree("tree");
RobotomyRequestForm robot("robot");
Bureaucrat melvin("melvin", 1);
pardon.beSigned(melvin);
tree.beSigned(melvin);
robot.beSigned(melvin);
print (CYAN SUB_TITTLE "Shrubbery\n" RESET);
tree.execute(melvin);
print (CYAN SUB_TITTLE "Robotomy\n" RESET);
robot.execute(melvin);
robot.execute(melvin);
robot.execute(melvin);
robot.execute(melvin);
print (CYAN SUB_TITTLE "Presidential\n" RESET);
pardon.execute(melvin);
}
void execute_exceptions()
{
ShrubberyCreationForm tree("tree");
Bureaucrat melvin ("melvin", 145);
try
{
tree.execute(melvin);
}
catch (const std::exception &e)
{
print (RED << e.what() << RESET);
}
tree.beSigned(melvin);
try
{
tree.execute(melvin);
}
catch (const std::exception &e)
{
print (RED << e.what() << RESET);
}
Bureaucrat best ("best", 1);
tree.execute(best);
}
void executeForm()
{
ShrubberyCreationForm tree("tree");
Bureaucrat melvin ("melvin", 145);
melvin.executeForm(tree);
tree.beSigned(melvin);
melvin.executeForm(tree);
for (int i = 0; i < 10; i++)
melvin.incrementGrade();
melvin.executeForm(tree);
}
}
int
main (void)
{
print (GREEN TITTLE "Creation Grades" RESET);
Tests::creation_grades();
print (GREEN TITTLE "Form Actions" RESET);
Tests::form_actions();
print (GREEN TITTLE "Form's Execute Excepions\n" RESET);
Tests::execute_exceptions();
print (GREEN TITTLE "Bureaucrat's ExecuteForm\n" RESET);
Tests::executeForm();
}