-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
90 lines (77 loc) · 3.16 KB
/
main.cpp
File metadata and controls
90 lines (77 loc) · 3.16 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zelhajou <zelhajou@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/26 16:37:19 by zelhajou #+# #+# */
/* Updated: 2024/12/29 18:15:23 by zelhajou ### ########.fr */
/* */
/* ************************************************************************** */
#include "Bureaucrat.hpp"
#include "ShrubberyCreationForm.hpp"
#include "RobotomyRequestForm.hpp"
#include "PresidentialPardonForm.hpp"
int main()
{
try
{
Bureaucrat highGrade("HighGrade", 1);
Bureaucrat midGrade("MidGrade", 50);
Bureaucrat lowGrade("LowGrade", 150);
std::cout << "\n-------- Test ShrubberyCreationForm --------\n";
{
ShrubberyCreationForm shrub("garden");
std::cout << shrub << std::endl;
std::cout << "\nTesting with low grade bureaucrat:\n";
lowGrade.signForm(shrub);
lowGrade.executeForm(shrub);
std::cout << "\nTesting with mid grade bureaucrat:\n";
midGrade.signForm(shrub);
midGrade.executeForm(shrub);
}
std::cout << "\n-------- Test RobotomyRequestForm --------\n";
{
RobotomyRequestForm robotomy("Target1");
std::cout << robotomy << std::endl;
std::cout << "\nTesting with mid grade bureaucrat:\n";
midGrade.signForm(robotomy);
midGrade.executeForm(robotomy);
std::cout << "\nTesting with high grade bureaucrat:\n";
highGrade.executeForm(robotomy);
}
std::cout << "\n-------- Test PresidentialPardonForm --------\n";
{
PresidentialPardonForm pardon("Criminal1");
std::cout << pardon << std::endl;
std::cout << "\nTesting execution without signature:\n";
highGrade.executeForm(pardon);
std::cout << "\nTesting complete process with high grade bureaucrat:\n";
highGrade.signForm(pardon);
highGrade.executeForm(pardon);
}
std::cout << "\n-------- Test Invalid Grade Creation --------\n";
try
{
Bureaucrat tooHigh("TooHigh", 0);
}
catch (std::exception &e)
{
std::cout << "Exception caught: " << e.what() << std::endl;
}
try
{
Bureaucrat tooLow("TooLow", 151);
}
catch (std::exception &e)
{
std::cout << "Exception caught: " << e.what() << std::endl;
}
}
catch (std::exception &e)
{
std::cout << "Unexpected exception: " << e.what() << std::endl;
}
return 0;
}