-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
81 lines (74 loc) · 2.61 KB
/
main.cpp
File metadata and controls
81 lines (74 loc) · 2.61 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zelhajou <zelhajou@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/25 12:57:31 by zelhajou #+# #+# */
/* Updated: 2024/12/27 17:16:29 by zelhajou ### ########.fr */
/* */
/* ************************************************************************** */
#include "Bureaucrat.hpp"
int main()
{
std::cout << "\n-------- Test 1: Valid Bureaucrat --------\n";
try
{
Bureaucrat sherif("Sherif", 75);
std::cout << sherif << std::endl;
std::cout << "Incrementing grade..." << std::endl;
sherif.incrementGrade();
std::cout << sherif << std::endl;
std::cout << "Decrementing grade..." << std::endl;
sherif.decrementGrade();
std::cout << sherif << std::endl;
}
catch (const std::exception &e)
{
std::cout << "Exception: " << e.what() << std::endl;
}
std::cout << "\n-------- Test 2: Grade Too High --------\n";
try
{
Bureaucrat sherifa("Sherifa", 0);
std::cout << sherifa << std::endl;
}
catch (const std::exception &e)
{
std::cout << "Exception: " << e.what() << std::endl;
}
std::cout << "\n-------- Test 3: Grade Too Low --------\n";
try
{
Bureaucrat sara("Sara", 151);
std::cout << sara << std::endl;
}
catch (const std::exception &e)
{
std::cout << "Exception: " << e.what() << std::endl;
}
std::cout << "\n-------- Test 4: Increment at Maximum Grade --------\n";
try
{
Bureaucrat max("Max", 1);
std::cout << max << std::endl;
max.incrementGrade();
}
catch (const std::exception &e)
{
std::cout << "Exception: " << e.what() << std::endl;
}
std::cout << "\n-------- Test 5: Decrement at Minimum Grade --------\n";
try
{
Bureaucrat min("Min", 150);
std::cout << min << std::endl;
min.decrementGrade();
}
catch (const std::exception &e)
{
std::cout << "Exception: " << e.what() << std::endl;
}
return 0;
}