diff --git a/ex00/inc/Bureaucrat.hpp b/ex00/inc/Bureaucrat.hpp index e880192..e571b9f 100644 --- a/ex00/inc/Bureaucrat.hpp +++ b/ex00/inc/Bureaucrat.hpp @@ -14,12 +14,20 @@ class Bureaucrat int _grade; public: + // Constructors Bureaucrat() = delete; Bureaucrat(std::string name, int grade); - Bureaucrat(Bureaucrat &other); - ~Bureaucrat(); - Bureaucrat &operator=(Bureaucrat &other) = delete; + // Copy constructor and copy assignment operator + Bureaucrat(const Bureaucrat &other); + Bureaucrat &operator=(const Bureaucrat &other) = delete; + + // Move constructor and move assignment operator + Bureaucrat(Bureaucrat &&other) noexcept; + Bureaucrat &operator=(Bureaucrat &&other) noexcept = delete; + + // Destructor + ~Bureaucrat(); Bureaucrat &operator++(); // Pre-increment Bureaucrat operator++(int); // Post-increment diff --git a/ex00/inc/colors.h b/ex00/inc/colors.h index 461f384..240bcd1 100644 --- a/ex00/inc/colors.h +++ b/ex00/inc/colors.h @@ -20,8 +20,6 @@ #define INVERSE_OFF "\033[27m" #define STRIKETHROUGH_OFF "\033[29m" -#define REVERSE "\033[7m" - #define BLACK "\033[30m" #define RED "\033[31m" #define GREEN "\033[32m" @@ -65,490 +63,18 @@ #define BACKGROUND14 "\033[48;5;14m" #define BACKGROUND15 "\033[48;5;15m" -// #define COLOR16 "\033[38;5;16m" -// #define COLOR17 "\033[38;5;17m" -// #define COLOR18 "\033[38;5;18m" -// #define COLOR19 "\033[38;5;19m" -// #define COLOR20 "\033[38;5;20m" -// #define COLOR21 "\033[38;5;21m" -// #define COLOR22 "\033[38;5;22m" -// #define COLOR23 "\033[38;5;23m" -// #define COLOR24 "\033[38;5;24m" -// #define COLOR25 "\033[38;5;25m" -// #define COLOR26 "\033[38;5;26m" -// #define COLOR27 "\033[38;5;27m" -// #define COLOR28 "\033[38;5;28m" -// #define COLOR29 "\033[38;5;29m" -// #define COLOR30 "\033[38;5;30m" -// #define COLOR31 "\033[38;5;31m" -// #define COLOR32 "\033[38;5;32m" -// #define COLOR33 "\033[38;5;33m" -// #define COLOR34 "\033[38;5;34m" -// #define COLOR35 "\033[38;5;35m" -// #define COLOR36 "\033[38;5;36m" -// #define COLOR37 "\033[38;5;37m" -// #define COLOR38 "\033[38;5;38m" -// #define COLOR39 "\033[38;5;39m" -// #define COLOR40 "\033[38;5;40m" -// #define COLOR41 "\033[38;5;41m" -// #define COLOR42 "\033[38;5;42m" -// #define COLOR43 "\033[38;5;43m" -// #define COLOR44 "\033[38;5;44m" -// #define COLOR45 "\033[38;5;45m" -// #define COLOR46 "\033[38;5;46m" -// #define COLOR47 "\033[38;5;47m" -// #define COLOR48 "\033[38;5;48m" -// #define COLOR49 "\033[38;5;49m" -// #define COLOR50 "\033[38;5;50m" -// #define COLOR51 "\033[38;5;51m" -// #define COLOR52 "\033[38;5;52m" -// #define COLOR53 "\033[38;5;53m" -// #define COLOR54 "\033[38;5;54m" -// #define COLOR55 "\033[38;5;55m" -// #define COLOR56 "\033[38;5;56m" -// #define COLOR57 "\033[38;5;57m" -// #define COLOR58 "\033[38;5;58m" -// #define COLOR59 "\033[38;5;59m" -// #define COLOR60 "\033[38;5;60m" -// #define COLOR61 "\033[38;5;61m" -// #define COLOR62 "\033[38;5;62m" -// #define COLOR63 "\033[38;5;63m" -// #define COLOR64 "\033[38;5;64m" -// #define COLOR65 "\033[38;5;65m" -// #define COLOR66 "\033[38;5;66m" -// #define COLOR67 "\033[38;5;67m" -// #define COLOR68 "\033[38;5;68m" -// #define COLOR69 "\033[38;5;69m" -// #define COLOR70 "\033[38;5;70m" -// #define COLOR71 "\033[38;5;71m" -// #define COLOR72 "\033[38;5;72m" -// #define COLOR73 "\033[38;5;73m" -// #define COLOR74 "\033[38;5;74m" -// #define COLOR75 "\033[38;5;75m" -// #define COLOR76 "\033[38;5;76m" -// #define COLOR77 "\033[38;5;77m" -// #define COLOR78 "\033[38;5;78m" -// #define COLOR79 "\033[38;5;79m" -// #define COLOR80 "\033[38;5;80m" -// #define COLOR81 "\033[38;5;81m" -// #define COLOR82 "\033[38;5;82m" -// #define COLOR83 "\033[38;5;83m" -// #define COLOR84 "\033[38;5;84m" -// #define COLOR85 "\033[38;5;85m" -// #define COLOR86 "\033[38;5;86m" -// #define COLOR87 "\033[38;5;87m" -// #define COLOR88 "\033[38;5;88m" -// #define COLOR89 "\033[38;5;89m" -// #define COLOR90 "\033[38;5;90m" -// #define COLOR91 "\033[38;5;91m" -// #define COLOR92 "\033[38;5;92m" -// #define COLOR93 "\033[38;5;93m" -// #define COLOR94 "\033[38;5;94m" -// #define COLOR95 "\033[38;5;95m" -// #define COLOR96 "\033[38;5;96m" -// #define COLOR97 "\033[38;5;97m" -// #define COLOR98 "\033[38;5;98m" -// #define COLOR99 "\033[38;5;99m" -// #define COLOR100 "\033[38;5;100m" -// #define COLOR101 "\033[38;5;101m" -// #define COLOR102 "\033[38;5;102m" -// #define COLOR103 "\033[38;5;103m" -// #define COLOR104 "\033[38;5;104m" -// #define COLOR105 "\033[38;5;105m" -// #define COLOR106 "\033[38;5;106m" -// #define COLOR107 "\033[38;5;107m" -// #define COLOR108 "\033[38;5;108m" -// #define COLOR109 "\033[38;5;109m" -// #define COLOR110 "\033[38;5;110m" -// #define COLOR111 "\033[38;5;111m" -// #define COLOR112 "\033[38;5;112m" -// #define COLOR113 "\033[38;5;113m" -// #define COLOR114 "\033[38;5;114m" -// #define COLOR115 "\033[38;5;115m" -// #define COLOR116 "\033[38;5;116m" -// #define COLOR117 "\033[38;5;117m" -// #define COLOR118 "\033[38;5;118m" -// #define COLOR119 "\033[38;5;119m" -// #define COLOR120 "\033[38;5;120m" -// #define COLOR121 "\033[38;5;121m" -// #define COLOR122 "\033[38;5;122m" -// #define COLOR123 "\033[38;5;123m" -// #define COLOR124 "\033[38;5;124m" -// #define COLOR125 "\033[38;5;125m" -// #define COLOR126 "\033[38;5;126m" -// #define COLOR127 "\033[38;5;127m" -// #define COLOR128 "\033[38;5;128m" -// #define COLOR129 "\033[38;5;129m" -// #define COLOR130 "\033[38;5;130m" -// #define COLOR131 "\033[38;5;131m" -// #define COLOR132 "\033[38;5;132m" -// #define COLOR133 "\033[38;5;133m" -// #define COLOR134 "\033[38;5;134m" -// #define COLOR135 "\033[38;5;135m" -// #define COLOR136 "\033[38;5;136m" -// #define COLOR137 "\033[38;5;137m" -// #define COLOR138 "\033[38;5;138m" -// #define COLOR139 "\033[38;5;139m" -// #define COLOR140 "\033[38;5;140m" -// #define COLOR141 "\033[38;5;141m" -// #define COLOR142 "\033[38;5;142m" -// #define COLOR143 "\033[38;5;143m" -// #define COLOR144 "\033[38;5;144m" -// #define COLOR145 "\033[38;5;145m" -// #define COLOR146 "\033[38;5;146m" -// #define COLOR147 "\033[38;5;147m" -// #define COLOR148 "\033[38;5;148m" -// #define COLOR149 "\033[38;5;149m" -// #define COLOR150 "\033[38;5;150m" -// #define COLOR151 "\033[38;5;151m" -// #define COLOR152 "\033[38;5;152m" -// #define COLOR153 "\033[38;5;153m" -// #define COLOR154 "\033[38;5;154m" -// #define COLOR155 "\033[38;5;155m" -// #define COLOR156 "\033[38;5;156m" -// #define COLOR157 "\033[38;5;157m" -// #define COLOR158 "\033[38;5;158m" -// #define COLOR159 "\033[38;5;159m" -// #define COLOR160 "\033[38;5;160m" -// #define COLOR161 "\033[38;5;161m" -// #define COLOR162 "\033[38;5;162m" -// #define COLOR163 "\033[38;5;163m" -// #define COLOR164 "\033[38;5;164m" -// #define COLOR165 "\033[38;5;165m" -// #define COLOR166 "\033[38;5;166m" -// #define COLOR167 "\033[38;5;167m" -// #define COLOR168 "\033[38;5;168m" -// #define COLOR169 "\033[38;5;169m" -// #define COLOR170 "\033[38;5;170m" -// #define COLOR171 "\033[38;5;171m" -// #define COLOR172 "\033[38;5;172m" -// #define COLOR173 "\033[38;5;173m" -// #define COLOR174 "\033[38;5;174m" -// #define COLOR175 "\033[38;5;175m" -// #define COLOR176 "\033[38;5;176m" -// #define COLOR177 "\033[38;5;177m" -// #define COLOR178 "\033[38;5;178m" -// #define COLOR179 "\033[38;5;179m" -// #define COLOR180 "\033[38;5;180m" -// #define COLOR181 "\033[38;5;181m" -// #define COLOR182 "\033[38;5;182m" -// #define COLOR183 "\033[38;5;183m" -// #define COLOR184 "\033[38;5;184m" -// #define COLOR185 "\033[38;5;185m" -// #define COLOR186 "\033[38;5;186m" -// #define COLOR187 "\033[38;5;187m" -// #define COLOR188 "\033[38;5;188m" -// #define COLOR189 "\033[38;5;189m" -// #define COLOR190 "\033[38;5;190m" -// #define COLOR191 "\033[38;5;191m" -// #define COLOR192 "\033[38;5;192m" -// #define COLOR193 "\033[38;5;193m" -// #define COLOR194 "\033[38;5;194m" -// #define COLOR195 "\033[38;5;195m" -// #define COLOR196 "\033[38;5;196m" -// #define COLOR197 "\033[38;5;197m" -// #define COLOR198 "\033[38;5;198m" -// #define COLOR199 "\033[38;5;199m" -// #define COLOR200 "\033[38;5;200m" -// #define COLOR201 "\033[38;5;201m" -// #define COLOR202 "\033[38;5;202m" -// #define COLOR203 "\033[38;5;203m" -// #define COLOR204 "\033[38;5;204m" -// #define COLOR205 "\033[38;5;205m" -// #define COLOR206 "\033[38;5;206m" -// #define COLOR207 "\033[38;5;207m" -// #define COLOR208 "\033[38;5;208m" -// #define COLOR209 "\033[38;5;209m" -// #define COLOR210 "\033[38;5;210m" -// #define COLOR211 "\033[38;5;211m" -// #define COLOR212 "\033[38;5;212m" -// #define COLOR213 "\033[38;5;213m" -// #define COLOR214 "\033[38;5;214m" -// #define COLOR215 "\033[38;5;215m" -// #define COLOR216 "\033[38;5;216m" -// #define COLOR217 "\033[38;5;217m" -// #define COLOR218 "\033[38;5;218m" -// #define COLOR219 "\033[38;5;219m" -// #define COLOR220 "\033[38;5;220m" -// #define COLOR221 "\033[38;5;221m" -// #define COLOR222 "\033[38;5;222m" -// #define COLOR223 "\033[38;5;223m" -// #define COLOR224 "\033[38;5;224m" -// #define COLOR225 "\033[38;5;225m" -// #define COLOR226 "\033[38;5;226m" -// #define COLOR227 "\033[38;5;227m" -// #define COLOR228 "\033[38;5;228m" -// #define COLOR229 "\033[38;5;229m" -// #define COLOR230 "\033[38;5;230m" -// #define COLOR231 "\033[38;5;231m" -// #define COLOR232 "\033[38;5;232m" -// #define COLOR233 "\033[38;5;233m" -// #define COLOR234 "\033[38;5;234m" -// #define COLOR235 "\033[38;5;235m" -// #define COLOR236 "\033[38;5;236m" -// #define COLOR237 "\033[38;5;237m" -// #define COLOR238 "\033[38;5;238m" -// #define COLOR239 "\033[38;5;239m" -// #define COLOR240 "\033[38;5;240m" -// #define COLOR241 "\033[38;5;241m" -// #define COLOR242 "\033[38;5;242m" -// #define COLOR243 "\033[38;5;243m" -// #define COLOR244 "\033[38;5;244m" -// #define COLOR245 "\033[38;5;245m" -// #define COLOR246 "\033[38;5;246m" -// #define COLOR247 "\033[38;5;247m" -// #define COLOR248 "\033[38;5;248m" -// #define COLOR249 "\033[38;5;249m" -// #define COLOR250 "\033[38;5;250m" -// #define COLOR251 "\033[38;5;251m" -// #define COLOR252 "\033[38;5;252m" -// #define COLOR253 "\033[38;5;253m" -// #define COLOR254 "\033[38;5;254m" -// #define COLOR255 "\033[38;5;255m" - - -// #define BACKGROUND16 "\033[48;5;16m" -// #define BACKGROUND17 "\033[48;5;17m" -// #define BACKGROUND18 "\033[48;5;18m" -// #define BACKGROUND19 "\033[48;5;19m" -// #define BACKGROUND20 "\033[48;5;20m" -// #define BACKGROUND21 "\033[48;5;21m" -// #define BACKGROUND22 "\033[48;5;22m" -// #define BACKGROUND23 "\033[48;5;23m" -// #define BACKGROUND24 "\033[48;5;24m" -// #define BACKGROUND25 "\033[48;5;25m" -// #define BACKGROUND26 "\033[48;5;26m" -// #define BACKGROUND27 "\033[48;5;27m" -// #define BACKGROUND28 "\033[48;5;28m" -// #define BACKGROUND29 "\033[48;5;29m" -// #define BACKGROUND30 "\033[48;5;30m" -// #define BACKGROUND31 "\033[48;5;31m" -// #define BACKGROUND32 "\033[48;5;32m" -// #define BACKGROUND33 "\033[48;5;33m" -// #define BACKGROUND34 "\033[48;5;34m" -// #define BACKGROUND35 "\033[48;5;35m" -// #define BACKGROUND36 "\033[48;5;36m" -// #define BACKGROUND37 "\033[48;5;37m" -// #define BACKGROUND38 "\033[48;5;38m" -// #define BACKGROUND39 "\033[48;5;39m" -// #define BACKGROUND40 "\033[48;5;40m" -// #define BACKGROUND41 "\033[48;5;41m" -// #define BACKGROUND42 "\033[48;5;42m" -// #define BACKGROUND43 "\033[48;5;43m" -// #define BACKGROUND44 "\033[48;5;44m" -// #define BACKGROUND45 "\033[48;5;45m" -// #define BACKGROUND46 "\033[48;5;46m" -// #define BACKGROUND47 "\033[48;5;47m" -// #define BACKGROUND48 "\033[48;5;48m" -// #define BACKGROUND49 "\033[48;5;49m" -// #define BACKGROUND50 "\033[48;5;50m" -// #define BACKGROUND51 "\033[48;5;51m" -// #define BACKGROUND52 "\033[48;5;52m" -// #define BACKGROUND53 "\033[48;5;53m" -// #define BACKGROUND54 "\033[48;5;54m" -// #define BACKGROUND55 "\033[48;5;55m" -// #define BACKGROUND56 "\033[48;5;56m" -// #define BACKGROUND57 "\033[48;5;57m" -// #define BACKGROUND58 "\033[48;5;58m" -// #define BACKGROUND59 "\033[48;5;59m" -// #define BACKGROUND60 "\033[48;5;60m" -// #define BACKGROUND61 "\033[48;5;61m" -// #define BACKGROUND62 "\033[48;5;62m" -// #define BACKGROUND63 "\033[48;5;63m" -// #define BACKGROUND64 "\033[48;5;64m" -// #define BACKGROUND65 "\033[48;5;65m" -// #define BACKGROUND66 "\033[48;5;66m" -// #define BACKGROUND67 "\033[48;5;67m" -// #define BACKGROUND68 "\033[48;5;68m" -// #define BACKGROUND69 "\033[48;5;69m" -// #define BACKGROUND70 "\033[48;5;70m" -// #define BACKGROUND71 "\033[48;5;71m" -// #define BACKGROUND72 "\033[48;5;72m" -// #define BACKGROUND73 "\033[48;5;73m" -// #define BACKGROUND74 "\033[48;5;74m" -// #define BACKGROUND75 "\033[48;5;75m" -// #define BACKGROUND76 "\033[48;5;76m" -// #define BACKGROUND77 "\033[48;5;77m" -// #define BACKGROUND78 "\033[48;5;78m" -// #define BACKGROUND79 "\033[48;5;79m" -// #define BACKGROUND80 "\033[48;5;80m" -// #define BACKGROUND81 "\033[48;5;81m" -// #define BACKGROUND82 "\033[48;5;82m" -// #define BACKGROUND83 "\033[48;5;83m" -// #define BACKGROUND84 "\033[48;5;84m" -// #define BACKGROUND85 "\033[48;5;85m" -// #define BACKGROUND86 "\033[48;5;86m" -// #define BACKGROUND87 "\033[48;5;87m" -// #define BACKGROUND88 "\033[48;5;88m" -// #define BACKGROUND89 "\033[48;5;89m" -// #define BACKGROUND90 "\033[48;5;90m" -// #define BACKGROUND91 "\033[48;5;91m" -// #define BACKGROUND92 "\033[48;5;92m" -// #define BACKGROUND93 "\033[48;5;93m" -// #define BACKGROUND94 "\033[48;5;94m" -// #define BACKGROUND95 "\033[48;5;95m" -// #define BACKGROUND96 "\033[48;5;96m" -// #define BACKGROUND97 "\033[48;5;97m" -// #define BACKGROUND98 "\033[48;5;98m" -// #define BACKGROUND99 "\033[48;5;99m" -// #define BACKGROUND100 "\033[48;5;100m" -// #define BACKGROUND101 "\033[48;5;101m" -// #define BACKGROUND102 "\033[48;5;102m" -// #define BACKGROUND103 "\033[48;5;103m" -// #define BACKGROUND104 "\033[48;5;104m" -// #define BACKGROUND105 "\033[48;5;105m" -// #define BACKGROUND106 "\033[48;5;106m" -// #define BACKGROUND107 "\033[48;5;107m" -// #define BACKGROUND108 "\033[48;5;108m" -// #define BACKGROUND109 "\033[48;5;109m" -// #define BACKGROUND110 "\033[48;5;110m" -// #define BACKGROUND111 "\033[48;5;111m" -// #define BACKGROUND112 "\033[48;5;112m" -// #define BACKGROUND113 "\033[48;5;113m" -// #define BACKGROUND114 "\033[48;5;114m" -// #define BACKGROUND115 "\033[48;5;115m" -// #define BACKGROUND116 "\033[48;5;116m" -// #define BACKGROUND117 "\033[48;5;117m" -// #define BACKGROUND118 "\033[48;5;118m" -// #define BACKGROUND119 "\033[48;5;119m" -// #define BACKGROUND120 "\033[48;5;120m" -// #define BACKGROUND121 "\033[48;5;121m" -// #define BACKGROUND122 "\033[48;5;122m" -// #define BACKGROUND123 "\033[48;5;123m" -// #define BACKGROUND124 "\033[48;5;124m" -// #define BACKGROUND125 "\033[48;5;125m" -// #define BACKGROUND126 "\033[48;5;126m" -// #define BACKGROUND127 "\033[48;5;127m" -// #define BACKGROUND128 "\033[48;5;128m" -// #define BACKGROUND129 "\033[48;5;129m" -// #define BACKGROUND130 "\033[48;5;130m" -// #define BACKGROUND131 "\033[48;5;131m" -// #define BACKGROUND132 "\033[48;5;132m" -// #define BACKGROUND133 "\033[48;5;133m" -// #define BACKGROUND134 "\033[48;5;134m" -// #define BACKGROUND135 "\033[48;5;135m" -// #define BACKGROUND136 "\033[48;5;136m" -// #define BACKGROUND137 "\033[48;5;137m" -// #define BACKGROUND138 "\033[48;5;138m" -// #define BACKGROUND139 "\033[48;5;139m" -// #define BACKGROUND140 "\033[48;5;140m" -// #define BACKGROUND141 "\033[48;5;141m" -// #define BACKGROUND142 "\033[48;5;142m" -// #define BACKGROUND143 "\033[48;5;143m" -// #define BACKGROUND144 "\033[48;5;144m" -// #define BACKGROUND145 "\033[48;5;145m" -// #define BACKGROUND146 "\033[48;5;146m" -// #define BACKGROUND147 "\033[48;5;147m" -// #define BACKGROUND148 "\033[48;5;148m" -// #define BACKGROUND149 "\033[48;5;149m" -// #define BACKGROUND150 "\033[48;5;150m" -// #define BACKGROUND151 "\033[48;5;151m" -// #define BACKGROUND152 "\033[48;5;152m" -// #define BACKGROUND153 "\033[48;5;153m" -// #define BACKGROUND154 "\033[48;5;154m" -// #define BACKGROUND155 "\033[48;5;155m" -// #define BACKGROUND156 "\033[48;5;156m" -// #define BACKGROUND157 "\033[48;5;157m" -// #define BACKGROUND158 "\033[48;5;158m" -// #define BACKGROUND159 "\033[48;5;159m" -// #define BACKGROUND160 "\033[48;5;160m" -// #define BACKGROUND161 "\033[48;5;161m" -// #define BACKGROUND162 "\033[48;5;162m" -// #define BACKGROUND163 "\033[48;5;163m" -// #define BACKGROUND164 "\033[48;5;164m" -// #define BACKGROUND165 "\033[48;5;165m" -// #define BACKGROUND166 "\033[48;5;166m" -// #define BACKGROUND167 "\033[48;5;167m" -// #define BACKGROUND168 "\033[48;5;168m" -// #define BACKGROUND169 "\033[48;5;169m" -// #define BACKGROUND170 "\033[48;5;170m" -// #define BACKGROUND171 "\033[48;5;171m" -// #define BACKGROUND172 "\033[48;5;172m" -// #define BACKGROUND173 "\033[48;5;173m" -// #define BACKGROUND174 "\033[48;5;174m" -// #define BACKGROUND175 "\033[48;5;175m" -// #define BACKGROUND176 "\033[48;5;176m" -// #define BACKGROUND177 "\033[48;5;177m" -// #define BACKGROUND178 "\033[48;5;178m" -// #define BACKGROUND179 "\033[48;5;179m" -// #define BACKGROUND180 "\033[48;5;180m" -// #define BACKGROUND181 "\033[48;5;181m" -// #define BACKGROUND182 "\033[48;5;182m" -// #define BACKGROUND183 "\033[48;5;183m" -// #define BACKGROUND184 "\033[48;5;184m" -// #define BACKGROUND185 "\033[48;5;185m" -// #define BACKGROUND186 "\033[48;5;186m" -// #define BACKGROUND187 "\033[48;5;187m" -// #define BACKGROUND188 "\033[48;5;188m" -// #define BACKGROUND189 "\033[48;5;189m" -// #define BACKGROUND190 "\033[48;5;190m" -// #define BACKGROUND191 "\033[48;5;191m" -// #define BACKGROUND192 "\033[48;5;192m" -// #define BACKGROUND193 "\033[48;5;193m" -// #define BACKGROUND194 "\033[48;5;194m" -// #define BACKGROUND195 "\033[48;5;195m" -// #define BACKGROUND196 "\033[48;5;196m" -// #define BACKGROUND197 "\033[48;5;197m" -// #define BACKGROUND198 "\033[48;5;198m" -// #define BACKGROUND199 "\033[48;5;199m" -// #define BACKGROUND200 "\033[48;5;200m" -// #define BACKGROUND201 "\033[48;5;201m" -// #define BACKGROUND202 "\033[48;5;202m" -// #define BACKGROUND203 "\033[48;5;203m" -// #define BACKGROUND204 "\033[48;5;204m" -// #define BACKGROUND205 "\033[48;5;205m" -// #define BACKGROUND206 "\033[48;5;206m" -// #define BACKGROUND207 "\033[48;5;207m" -// #define BACKGROUND208 "\033[48;5;208m" -// #define BACKGROUND209 "\033[48;5;209m" -// #define BACKGROUND210 "\033[48;5;210m" -// #define BACKGROUND211 "\033[48;5;211m" -// #define BACKGROUND212 "\033[48;5;212m" -// #define BACKGROUND213 "\033[48;5;213m" -// #define BACKGROUND214 "\033[48;5;214m" -// #define BACKGROUND215 "\033[48;5;215m" -// #define BACKGROUND216 "\033[48;5;216m" -// #define BACKGROUND217 "\033[48;5;217m" -// #define BACKGROUND218 "\033[48;5;218m" -// #define BACKGROUND219 "\033[48;5;219m" -// #define BACKGROUND220 "\033[48;5;220m" -// #define BACKGROUND221 "\033[48;5;221m" -// #define BACKGROUND222 "\033[48;5;222m" -// #define BACKGROUND223 "\033[48;5;223m" -// #define BACKGROUND224 "\033[48;5;224m" -// #define BACKGROUND225 "\033[48;5;225m" -// #define BACKGROUND226 "\033[48;5;226m" -// #define BACKGROUND227 "\033[48;5;227m" -// #define BACKGROUND228 "\033[48;5;228m" -// #define BACKGROUND229 "\033[48;5;229m" -// #define BACKGROUND230 "\033[48;5;230m" -// #define BACKGROUND231 "\033[48;5;231m" -// #define BACKGROUND232 "\033[48;5;232m" -// #define BACKGROUND233 "\033[48;5;233m" -// #define BACKGROUND234 "\033[48;5;234m" -// #define BACKGROUND235 "\033[48;5;235m" -// #define BACKGROUND236 "\033[48;5;236m" -// #define BACKGROUND237 "\033[48;5;237m" -// #define BACKGROUND238 "\033[48;5;238m" -// #define BACKGROUND239 "\033[48;5;239m" -// #define BACKGROUND240 "\033[48;5;240m" -// #define BACKGROUND241 "\033[48;5;241m" -// #define BACKGROUND242 "\033[48;5;242m" -// #define BACKGROUND243 "\033[48;5;243m" -// #define BACKGROUND244 "\033[48;5;244m" -// #define BACKGROUND245 "\033[48;5;245m" -// #define BACKGROUND246 "\033[48;5;246m" -// #define BACKGROUND247 "\033[48;5;247m" -// #define BACKGROUND248 "\033[48;5;248m" -// #define BACKGROUND249 "\033[48;5;249m" -// #define BACKGROUND250 "\033[48;5;250m" -// #define BACKGROUND251 "\033[48;5;251m" -// #define BACKGROUND252 "\033[48;5;252m" -// #define BACKGROUND253 "\033[48;5;253m" -// #define BACKGROUND254 "\033[48;5;254m" -// #define BACKGROUND255 "\033[48;5;255m" - - +#define CONSTRUCTOR "Constructor called" +#define PARAMETERIZED_CONSTRUCTOR "Parameterized constructor called" +#define ASSIGNMENT_OPERATOR "Assignment operator called" +#define DESTRUCTOR "Destructor called" +#define COPY_CONSTRUCTOR "Copy constructor called" +#define MOVE_CONSTRUCTOR "Move constructor called" +#define EXCEPTION BOLD BACKGROUND9 " Exception: " RESET " " +#define INFO ITALIC BOLD UNDERLINE GREEN "Info: " +#define PRINT BOLD BACKGROUND7 " Print: " RESET " " +#define END_SCOPE ITALIC BOLD UNDERLINE RED "End of scope" RESET +#define END_SCOPE_EXCEPTION \ + ITALIC BOLD UNDERLINE RED "End of scope with exception" RESET #endif \ No newline at end of file diff --git a/ex00/src/Bureaucrat.cpp b/ex00/src/Bureaucrat.cpp index 65bb96f..9802633 100644 --- a/ex00/src/Bureaucrat.cpp +++ b/ex00/src/Bureaucrat.cpp @@ -4,17 +4,11 @@ #include "colors.h" -#define COLOR BOLD BACKGROUND4 -#define BUREAUCRAT COLOR " Bureaucrat: " RESET " " -#define CONSTRUCTOR BUREAUCRAT "constructor called" -#define PARAMETERIZED_CONSTRUCTOR BUREAUCRAT "parameterized constructor called" -#define DESTRUCTOR BUREAUCRAT "destructor called" -#define COPY_CONSTRUCTOR BUREAUCRAT "copy constructor called" -#define COPY_ASSIGNMENT BUREAUCRAT "copy assignment operator called" +#define BUREAUCRAT BOLD BACKGROUND4 " Bureaucrat: " RESET " " Bureaucrat::Bureaucrat(std::string name, int grade) : _name(name) { - std::cout << PARAMETERIZED_CONSTRUCTOR << std::endl; + std::cout << BUREAUCRAT PARAMETERIZED_CONSTRUCTOR << std::endl; if (grade < HIGHEST_GRADE) throw(Bureaucrat::GradeTooHighException()); if (grade > LOWEST_GRADE) @@ -23,16 +17,23 @@ Bureaucrat::Bureaucrat(std::string name, int grade) : _name(name) std::cout << BUREAUCRAT << *this << std::endl; } -Bureaucrat::Bureaucrat(Bureaucrat &other) +Bureaucrat::Bureaucrat(const Bureaucrat &other) : _name(other._name), _grade(other._grade) { - std::cout << COPY_CONSTRUCTOR << std::endl; + std::cout << BUREAUCRAT COPY_CONSTRUCTOR << std::endl; + std::cout << BUREAUCRAT << *this << std::endl; +} + +Bureaucrat::Bureaucrat(Bureaucrat &&other) noexcept + : _name(std::move(other._name)), _grade(other._grade) +{ + std::cout << BUREAUCRAT MOVE_CONSTRUCTOR << std::endl; std::cout << BUREAUCRAT << *this << std::endl; } Bureaucrat::~Bureaucrat() { - std::cout << DESTRUCTOR << std::endl; + std::cout << BUREAUCRAT DESTRUCTOR << std::endl; } Bureaucrat &Bureaucrat::operator++() // Pre-increment @@ -87,7 +88,7 @@ const char *Bureaucrat::GradeTooLowException::what() const throw() std::ostream &operator<<(std::ostream &os, const Bureaucrat &bureaucrat) { - std::cout << bureaucrat.getName() << ", bureaucrat grade " - << bureaucrat.getGrade(); + os << bureaucrat.getName() << ", bureaucrat grade " + << bureaucrat.getGrade() << "."; return os; } diff --git a/ex00/src/main.cpp b/ex00/src/main.cpp index 2a1a374..02ae947 100644 --- a/ex00/src/main.cpp +++ b/ex00/src/main.cpp @@ -5,11 +5,6 @@ #include "colors.h" -#define EXCEPTION_COLOR BOLD BACKGROUND1 -#define EXCEPTION EXCEPTION_COLOR " Exception: " RESET " " -#define INFO_COLOR ITALIC BOLD UNDERLINE GREEN -#define INFO INFO_COLOR "Info: " - int main(void) { try diff --git a/ex01/inc/Bureaucrat.hpp b/ex01/inc/Bureaucrat.hpp index f8ccb34..f726bf0 100644 --- a/ex01/inc/Bureaucrat.hpp +++ b/ex01/inc/Bureaucrat.hpp @@ -14,12 +14,20 @@ class Bureaucrat int _grade; public: + // Constructors Bureaucrat() = delete; Bureaucrat(std::string name, int grade); - Bureaucrat(Bureaucrat &other); - ~Bureaucrat(); - Bureaucrat &operator=(Bureaucrat &other) = delete; + // Copy constructor and copy assignment operator + Bureaucrat(const Bureaucrat &other); + Bureaucrat &operator=(const Bureaucrat &other) = delete; + + // Move constructor and move assignment operator + Bureaucrat(Bureaucrat &&other) noexcept; + Bureaucrat &operator=(Bureaucrat &&other) noexcept = delete; + + // Destructor + ~Bureaucrat(); Bureaucrat &operator++(); // Pre-increment Bureaucrat operator++(int); // Post-increment @@ -32,11 +40,13 @@ class Bureaucrat class GradeTooHighException : public std::exception { + public: const char *what() const throw(); }; class GradeTooLowException : public std::exception { + public: const char *what() const throw(); }; }; diff --git a/ex01/inc/Form.hpp b/ex01/inc/Form.hpp index 419abfa..3169d84 100644 --- a/ex01/inc/Form.hpp +++ b/ex01/inc/Form.hpp @@ -15,11 +15,21 @@ class Form const int _executeGrade; public: + // Constructors Form() = delete; Form(std::string name, int signGrade, int executeGrade); + + // Copy constructor and copy assignment operator Form(const Form &other); + Form &operator=(const Form &other) = delete; + + // Move constructor and move assignment operator + Form(Form &&other) noexcept; + Form &operator=(Form &&other) noexcept = delete; + + // Destructor ~Form(); - Form &operator=(const Form &other) = delete; + const std::string &getName() const; bool getIsSigned() const; int getSignGrade() const; diff --git a/ex01/inc/colors.h b/ex01/inc/colors.h index 71190da..240bcd1 100644 --- a/ex01/inc/colors.h +++ b/ex01/inc/colors.h @@ -63,4 +63,18 @@ #define BACKGROUND14 "\033[48;5;14m" #define BACKGROUND15 "\033[48;5;15m" +#define CONSTRUCTOR "Constructor called" +#define PARAMETERIZED_CONSTRUCTOR "Parameterized constructor called" +#define ASSIGNMENT_OPERATOR "Assignment operator called" +#define DESTRUCTOR "Destructor called" +#define COPY_CONSTRUCTOR "Copy constructor called" +#define MOVE_CONSTRUCTOR "Move constructor called" + +#define EXCEPTION BOLD BACKGROUND9 " Exception: " RESET " " +#define INFO ITALIC BOLD UNDERLINE GREEN "Info: " +#define PRINT BOLD BACKGROUND7 " Print: " RESET " " +#define END_SCOPE ITALIC BOLD UNDERLINE RED "End of scope" RESET +#define END_SCOPE_EXCEPTION \ + ITALIC BOLD UNDERLINE RED "End of scope with exception" RESET + #endif \ No newline at end of file diff --git a/ex01/src/Bureaucrat.cpp b/ex01/src/Bureaucrat.cpp index 76e8b81..12181fe 100644 --- a/ex01/src/Bureaucrat.cpp +++ b/ex01/src/Bureaucrat.cpp @@ -6,11 +6,7 @@ #include "colors.h" -#define BUREAUCRAT BOLD BACKGROUND4 " Bureaucrat: " RESET " " -#define CONSTRUCTOR "Constructor called" -#define PARAMETERIZED_CONSTRUCTOR "Parameterized constructor called" -#define DESTRUCTOR "Destructor called" -#define COPY_CONSTRUCTOR "Copy constructor called" +#define BUREAUCRAT BOLD BACKGROUND4 " Bureaucrat: " RESET " " Bureaucrat::Bureaucrat(std::string name, int grade) : _name(name) { @@ -23,13 +19,20 @@ Bureaucrat::Bureaucrat(std::string name, int grade) : _name(name) std::cout << BUREAUCRAT << *this << std::endl; } -Bureaucrat::Bureaucrat(Bureaucrat &other) +Bureaucrat::Bureaucrat(const Bureaucrat &other) : _name(other._name), _grade(other._grade) { std::cout << BUREAUCRAT COPY_CONSTRUCTOR << std::endl; std::cout << BUREAUCRAT << *this << std::endl; } +Bureaucrat::Bureaucrat(Bureaucrat &&other) noexcept + : _name(std::move(other._name)), _grade(other._grade) +{ + std::cout << BUREAUCRAT MOVE_CONSTRUCTOR << std::endl; + std::cout << BUREAUCRAT << *this << std::endl; +} + Bureaucrat::~Bureaucrat() { std::cout << BUREAUCRAT DESTRUCTOR << std::endl; @@ -102,7 +105,7 @@ const char *Bureaucrat::GradeTooLowException::what() const throw() std::ostream &operator<<(std::ostream &os, const Bureaucrat &bureaucrat) { - std::cout << bureaucrat.getName() << ", bureaucrat grade " - << bureaucrat.getGrade(); + os << bureaucrat.getName() << ", bureaucrat grade " << bureaucrat.getGrade() + << "."; return os; } diff --git a/ex01/src/Form.cpp b/ex01/src/Form.cpp index f9eef30..bf6ab2c 100644 --- a/ex01/src/Form.cpp +++ b/ex01/src/Form.cpp @@ -5,11 +5,7 @@ #include "colors.h" -#define FORM BOLD BACKGROUND5 " Form: " RESET " " -#define CONSTRUCTOR "Constructor called" -#define PARAMETERIZED_CONSTRUCTOR "Parameterized constructor called" -#define DESTRUCTOR "Destructor called" -#define COPY_CONSTRUCTOR "Copy constructor called" +#define FORM BOLD BACKGROUND5 " Form: " RESET " " Form::Form(std::string name, int signGrade, int executeGrade) : _name(name), @@ -35,6 +31,16 @@ Form::Form(const Form &other) std::cout << FORM << *this << std::endl; } +Form::Form(Form &&other) noexcept + : _name(std::move(other._name)), + _isSigned(other._isSigned), + _signGrade(other._signGrade), + _executeGrade(other._executeGrade) +{ + std::cout << FORM MOVE_CONSTRUCTOR << std::endl; + std::cout << FORM << *this << std::endl; +} + Form::~Form() { std::cout << FORM DESTRUCTOR << std::endl; diff --git a/ex01/src/main.cpp b/ex01/src/main.cpp index 33d7c33..5cecbb4 100644 --- a/ex01/src/main.cpp +++ b/ex01/src/main.cpp @@ -6,13 +6,6 @@ #include "colors.h" -#define EXCEPTION BOLD BACKGROUND1 " Exception: " RESET " " -#define INFO ITALIC BOLD UNDERLINE GREEN "Info: " -#define PRINT BOLD BACKGROUND3 " Print: " RESET " " -#define END_SCOPE ITALIC BOLD UNDERLINE RED "End of scope" RESET -#define END_SCOPE_EXCEPTION \ - ITALIC BOLD UNDERLINE RED "End of scope with exception" RESET - int main(void) { try diff --git a/ex02/inc/AForm.hpp b/ex02/inc/AForm.hpp index 0cee4f7..6ddac11 100644 --- a/ex02/inc/AForm.hpp +++ b/ex02/inc/AForm.hpp @@ -15,11 +15,21 @@ class AForm const int _executeGrade; public: + // Constructors AForm() = delete; AForm(std::string name, int signGrade, int executeGrade); + + // Copy constructor and copy assignment operator AForm(const AForm &other); - ~AForm(); - AForm &operator=(const AForm &other) = delete; + AForm &operator=(const AForm &other) = delete; + + // Move constructor and move assignment operator + AForm(AForm &&other) noexcept; + AForm &operator=(AForm &&other) noexcept = delete; + + // Destructor + virtual ~AForm(); + const std::string &getName() const; bool getIsSigned() const; int getSignGrade() const; diff --git a/ex02/inc/Bureaucrat.hpp b/ex02/inc/Bureaucrat.hpp index 8b2f6eb..e1a9c04 100644 --- a/ex02/inc/Bureaucrat.hpp +++ b/ex02/inc/Bureaucrat.hpp @@ -6,6 +6,7 @@ #define HIGHEST_GRADE 1 #define LOWEST_GRADE 150 +class AForm; class Bureaucrat { @@ -14,12 +15,20 @@ class Bureaucrat int _grade; public: + // Constructors Bureaucrat() = delete; Bureaucrat(std::string name, int grade); - Bureaucrat(Bureaucrat &other); - ~Bureaucrat(); - Bureaucrat &operator=(Bureaucrat &other) = delete; + // Copy constructor and copy assignment operator + Bureaucrat(const Bureaucrat &other); + Bureaucrat &operator=(const Bureaucrat &other) = delete; + + // Move constructor and move assignment operator + Bureaucrat(Bureaucrat &&other) noexcept; + Bureaucrat &operator=(Bureaucrat &&other) noexcept = delete; + + // Destructor + ~Bureaucrat(); Bureaucrat &operator++(); // Pre-increment Bureaucrat operator++(int); // Post-increment @@ -28,15 +37,18 @@ class Bureaucrat int getGrade() const; const std::string getName() const; - void signForm(class AForm &form); + void signForm(AForm &form); + void executeForm(const AForm &form) const; class GradeTooHighException : public std::exception { + public: const char *what() const throw(); }; class GradeTooLowException : public std::exception { + public: const char *what() const throw(); }; }; diff --git a/ex02/inc/PresidentialPardonForm.hpp b/ex02/inc/PresidentialPardonForm.hpp index 80e2b1f..13a5c44 100644 --- a/ex02/inc/PresidentialPardonForm.hpp +++ b/ex02/inc/PresidentialPardonForm.hpp @@ -11,13 +11,23 @@ class PresidentialPardonForm : public AForm const std::string _target; public: + // Constructors PresidentialPardonForm() = delete; PresidentialPardonForm(std::string target); + + // Copy constructor and copy assignment operator PresidentialPardonForm(const PresidentialPardonForm &other); - ~PresidentialPardonForm(); PresidentialPardonForm &operator=(const PresidentialPardonForm &other) = delete; + // Move constructor and move assignment operator + PresidentialPardonForm(PresidentialPardonForm &&other) noexcept; + PresidentialPardonForm &operator=(PresidentialPardonForm &&other) noexcept = + delete; + + // Destructor + ~PresidentialPardonForm(); + void execute(const Bureaucrat &executor) const override; const std::string getTarget() const; }; diff --git a/ex02/inc/RobotomyRequestForm.hpp b/ex02/inc/RobotomyRequestForm.hpp index d8edaf2..11e25d7 100644 --- a/ex02/inc/RobotomyRequestForm.hpp +++ b/ex02/inc/RobotomyRequestForm.hpp @@ -11,12 +11,22 @@ class RobotomyRequestForm : public AForm const std::string _target; public: + // Constructors RobotomyRequestForm() = delete; RobotomyRequestForm(std::string target); + + // Copy constructor and copy assignment operator RobotomyRequestForm(const RobotomyRequestForm &other); - ~RobotomyRequestForm(); RobotomyRequestForm &operator=(const RobotomyRequestForm &other) = delete; + // Move constructor and move assignment operator + RobotomyRequestForm(RobotomyRequestForm &&other) noexcept; + RobotomyRequestForm &operator=(RobotomyRequestForm &&other) noexcept = + delete; + + // Destructor + ~RobotomyRequestForm(); + void execute(const Bureaucrat &executor) const override; const std::string getTarget() const; }; diff --git a/ex02/inc/ShrubberyCreationForm.hpp b/ex02/inc/ShrubberyCreationForm.hpp index 98a6a6f..f0c4f5b 100644 --- a/ex02/inc/ShrubberyCreationForm.hpp +++ b/ex02/inc/ShrubberyCreationForm.hpp @@ -11,13 +11,23 @@ class ShrubberyCreationForm : public AForm const std::string _target; public: - ShrubberyCreationForm() = delete; // Default constructor is deleted + // Constructors + ShrubberyCreationForm() = delete; ShrubberyCreationForm(std::string target); + + // Copy constructor and copy assignment operator ShrubberyCreationForm(const ShrubberyCreationForm &other); - ~ShrubberyCreationForm(); ShrubberyCreationForm &operator=(const ShrubberyCreationForm &other) = delete; + // Move constructor and move assignment operator + ShrubberyCreationForm(ShrubberyCreationForm &&other) noexcept; + ShrubberyCreationForm &operator=(ShrubberyCreationForm &&other) noexcept = + delete; + + // Destructor + ~ShrubberyCreationForm(); + void execute(const Bureaucrat &executor) const override; const std::string getTarget() const; }; diff --git a/ex02/inc/colors.h b/ex02/inc/colors.h index ba43697..240bcd1 100644 --- a/ex02/inc/colors.h +++ b/ex02/inc/colors.h @@ -1,23 +1,6 @@ #ifndef COLORS_H #define COLORS_H -#define BUREAUCRAT BOLD BACKGROUND4 " Bureaucrat: " RESET " " -#define AFORM BOLD BACKGROUND5 " AForm: " RESET " " -#define SHRUBBERY_CREATION_FORM BOLD BACKGROUND10 " ShrubberyCreationForm: " RESET " " -#define ROBOTOMY_REQUEST_FORM BOLD BACKGROUND11 " RobotomyRequestForm: " RESET " " -#define PRESIDENTIAL_PARDON_FORM BOLD BACKGROUND8 " PresidentialPardonForm: " RESET " " - -#define CONSTRUCTOR "Constructor called" -#define PARAMETERIZED_CONSTRUCTOR "Parameterized constructor called" -#define DESTRUCTOR "Destructor called" -#define COPY_CONSTRUCTOR "Copy constructor called" - -#define EXCEPTION BOLD BACKGROUND9 " Exception: " RESET " " -#define INFO ITALIC BOLD UNDERLINE GREEN "Info: " -#define PRINT BOLD BACKGROUND7 " Print: " RESET " " -#define END_SCOPE ITALIC BOLD UNDERLINE RED "End of scope" RESET -#define END_SCOPE_EXCEPTION ITALIC BOLD UNDERLINE RED "End of scope with exception" RESET - #define RESET "\033[m" #define BOLD_UNDERLINE "\033[1;4m" @@ -80,4 +63,18 @@ #define BACKGROUND14 "\033[48;5;14m" #define BACKGROUND15 "\033[48;5;15m" -#endif +#define CONSTRUCTOR "Constructor called" +#define PARAMETERIZED_CONSTRUCTOR "Parameterized constructor called" +#define ASSIGNMENT_OPERATOR "Assignment operator called" +#define DESTRUCTOR "Destructor called" +#define COPY_CONSTRUCTOR "Copy constructor called" +#define MOVE_CONSTRUCTOR "Move constructor called" + +#define EXCEPTION BOLD BACKGROUND9 " Exception: " RESET " " +#define INFO ITALIC BOLD UNDERLINE GREEN "Info: " +#define PRINT BOLD BACKGROUND7 " Print: " RESET " " +#define END_SCOPE ITALIC BOLD UNDERLINE RED "End of scope" RESET +#define END_SCOPE_EXCEPTION \ + ITALIC BOLD UNDERLINE RED "End of scope with exception" RESET + +#endif \ No newline at end of file diff --git a/ex02/src/AForm.cpp b/ex02/src/AForm.cpp index e8bd619..275a487 100644 --- a/ex02/src/AForm.cpp +++ b/ex02/src/AForm.cpp @@ -5,6 +5,8 @@ #include "colors.h" +#define AFORM BOLD BACKGROUND5 " AForm: " RESET " " + AForm::AForm(std::string name, int signGrade, int executeGrade) : _name(name), _isSigned(false), @@ -29,6 +31,16 @@ AForm::AForm(const AForm &other) std::cout << AFORM << *this << std::endl; } +AForm::AForm(AForm &&other) noexcept + : _name(std::move(other._name)), + _isSigned(other._isSigned), + _signGrade(other._signGrade), + _executeGrade(other._executeGrade) +{ + std::cout << AFORM MOVE_CONSTRUCTOR << std::endl; + std::cout << AFORM << *this << std::endl; +} + AForm::~AForm() { std::cout << AFORM DESTRUCTOR << std::endl; diff --git a/ex02/src/Bureaucrat.cpp b/ex02/src/Bureaucrat.cpp index 5ed5eb7..d1833d1 100644 --- a/ex02/src/Bureaucrat.cpp +++ b/ex02/src/Bureaucrat.cpp @@ -6,6 +6,8 @@ #include "colors.h" +#define BUREAUCRAT BOLD BACKGROUND4 " Bureaucrat: " RESET " " + Bureaucrat::Bureaucrat(std::string name, int grade) : _name(name) { std::cout << BUREAUCRAT PARAMETERIZED_CONSTRUCTOR << std::endl; @@ -17,13 +19,20 @@ Bureaucrat::Bureaucrat(std::string name, int grade) : _name(name) std::cout << BUREAUCRAT << *this << std::endl; } -Bureaucrat::Bureaucrat(Bureaucrat &other) +Bureaucrat::Bureaucrat(const Bureaucrat &other) : _name(other._name), _grade(other._grade) { std::cout << BUREAUCRAT COPY_CONSTRUCTOR << std::endl; std::cout << BUREAUCRAT << *this << std::endl; } +Bureaucrat::Bureaucrat(Bureaucrat &&other) noexcept + : _name(std::move(other._name)), _grade(other._grade) +{ + std::cout << BUREAUCRAT MOVE_CONSTRUCTOR << std::endl; + std::cout << BUREAUCRAT << *this << std::endl; +} + Bureaucrat::~Bureaucrat() { std::cout << BUREAUCRAT DESTRUCTOR << std::endl; @@ -84,6 +93,21 @@ void Bureaucrat::signForm(AForm &form) } } +void Bureaucrat::executeForm(const AForm &form) const +{ + try + { + form.execute(*this); + std::cout << BUREAUCRAT << _name << " executes " << form.getName() + << std::endl; + } + catch (std::exception &e) + { + std::cout << EXCEPTION << _name << " cannot execute " << form.getName() + << " because: " << e.what() << std::endl; + } +} + const char *Bureaucrat::GradeTooHighException::what() const throw() { return "Grade too high!"; @@ -96,7 +120,7 @@ const char *Bureaucrat::GradeTooLowException::what() const throw() std::ostream &operator<<(std::ostream &os, const Bureaucrat &bureaucrat) { - std::cout << bureaucrat.getName() << ", bureaucrat grade " - << bureaucrat.getGrade(); + os << bureaucrat.getName() << ", bureaucrat grade " + << bureaucrat.getGrade() << "."; return os; } diff --git a/ex02/src/PresidentialPardonForm.cpp b/ex02/src/PresidentialPardonForm.cpp index 2c82e2c..f96220d 100644 --- a/ex02/src/PresidentialPardonForm.cpp +++ b/ex02/src/PresidentialPardonForm.cpp @@ -7,6 +7,9 @@ #include "colors.h" +#define PRESIDENTIAL_PARDON_FORM \ + BOLD BACKGROUND8 " PresidentialPardonForm: " RESET " " + PresidentialPardonForm::PresidentialPardonForm(std::string target) : AForm("Presidential Pardon", 25, 5), _target(target) { @@ -28,6 +31,14 @@ PresidentialPardonForm::PresidentialPardonForm( std::cout << PRESIDENTIAL_PARDON_FORM << *this << std::endl; } +PresidentialPardonForm::PresidentialPardonForm( + PresidentialPardonForm &&other) noexcept + : AForm(std::move(other)), _target(std::move(other._target)) +{ + std::cout << PRESIDENTIAL_PARDON_FORM MOVE_CONSTRUCTOR << std::endl; + std::cout << PRESIDENTIAL_PARDON_FORM << *this << std::endl; +} + std::ostream &operator<<(std::ostream &os, const PresidentialPardonForm &form) { os << form.getName() @@ -43,7 +54,7 @@ void PresidentialPardonForm::execute(const Bureaucrat &executor) const isExecutable(executor); std::cout << PRESIDENTIAL_PARDON_FORM << executor.getName() - << " made shure Zaphod Beeblebrox pardoned " << _target << "." + << " made sure Zaphod Beeblebrox pardoned " << _target << "." << std::endl; } diff --git a/ex02/src/RobotomyRequestForm.cpp b/ex02/src/RobotomyRequestForm.cpp index 311d8fb..482067a 100644 --- a/ex02/src/RobotomyRequestForm.cpp +++ b/ex02/src/RobotomyRequestForm.cpp @@ -7,6 +7,9 @@ #include "colors.h" +#define ROBOTOMY_REQUEST_FORM \ + BOLD BACKGROUND11 " RobotomyRequestForm: " RESET " " + RobotomyRequestForm::RobotomyRequestForm(std::string target) : AForm("Robotomy Request", 72, 45), _target(target) { @@ -19,6 +22,12 @@ RobotomyRequestForm::RobotomyRequestForm(const RobotomyRequestForm &other) std::cout << ROBOTOMY_REQUEST_FORM COPY_CONSTRUCTOR << std::endl; } +RobotomyRequestForm::RobotomyRequestForm(RobotomyRequestForm &&other) noexcept + : AForm(std::move(other)), _target(std::move(other._target)) +{ + std::cout << ROBOTOMY_REQUEST_FORM MOVE_CONSTRUCTOR << std::endl; +} + RobotomyRequestForm::~RobotomyRequestForm() { std::cout << ROBOTOMY_REQUEST_FORM DESTRUCTOR << std::endl; diff --git a/ex02/src/ShrubberyCreationForm.cpp b/ex02/src/ShrubberyCreationForm.cpp index fa39240..1d3c91c 100644 --- a/ex02/src/ShrubberyCreationForm.cpp +++ b/ex02/src/ShrubberyCreationForm.cpp @@ -8,6 +8,9 @@ #include "colors.h" +#define SHRUBBERY_CREATION_FORM \ + BOLD BACKGROUND10 " ShrubberyCreationForm: " RESET " " + ShrubberyCreationForm::ShrubberyCreationForm(std::string target) : AForm("Shrubbery Creation", 145, 137), _target(target) { @@ -22,6 +25,14 @@ ShrubberyCreationForm::ShrubberyCreationForm(const ShrubberyCreationForm &other) std::cout << SHRUBBERY_CREATION_FORM << *this << std::endl; } +ShrubberyCreationForm::ShrubberyCreationForm( + ShrubberyCreationForm &&other) noexcept + : AForm(std::move(other)), _target(std::move(other._target)) +{ + std::cout << SHRUBBERY_CREATION_FORM MOVE_CONSTRUCTOR << std::endl; + std::cout << SHRUBBERY_CREATION_FORM << *this << std::endl; +} + ShrubberyCreationForm::~ShrubberyCreationForm() { std::cout << SHRUBBERY_CREATION_FORM DESTRUCTOR << std::endl; diff --git a/ex02/src/main.cpp b/ex02/src/main.cpp index 7d92e70..5570544 100644 --- a/ex02/src/main.cpp +++ b/ex02/src/main.cpp @@ -25,7 +25,8 @@ void test(Bureaucrat &bureaucrat) std::cout << PRINT << shrubberyForm << "\n" << std::endl; std::cout << INFO << "Executing ShrubberyCreationForm" << std::endl; - shrubberyForm.execute(bureaucrat); + bureaucrat.executeForm(shrubberyForm); + std::cout << "\n" << std::endl; std::cout << INFO << "Creating RobotomyRequestForm" << std::endl; RobotomyRequestForm robotomyForm("Alice"); @@ -36,7 +37,7 @@ void test(Bureaucrat &bureaucrat) std::cout << PRINT << robotomyForm << "\n" << std::endl; std::cout << INFO << "Executing RobotomyRequestForm" << std::endl; - robotomyForm.execute(bureaucrat); + bureaucrat.executeForm(robotomyForm); std::cout << "\n" << std::endl; std::cout << INFO << "Creating PresidentialPardonForm" << std::endl; @@ -48,7 +49,7 @@ void test(Bureaucrat &bureaucrat) std::cout << PRINT << pardonForm << "\n" << std::endl; std::cout << INFO << "Executing PresidentialPardonForm" << std::endl; - pardonForm.execute(bureaucrat); + bureaucrat.executeForm(pardonForm); std::cout << "\n" << END_SCOPE << std::endl; } catch (const std::exception &e) @@ -60,7 +61,8 @@ int main(void) { for (int i = 0; i < 250; i += 10) { - std::cout << INFO << "Testing Bureaucrat with grade: " << i << std::endl; + std::cout << INFO << "Testing Bureaucrat with grade: " << i + << std::endl; try { Bureaucrat bureaucrat("John", i); @@ -72,7 +74,6 @@ int main(void) std::cerr << EXCEPTION << e.what() << std::endl; } std::cout << std::endl; - } return 0; diff --git a/ex03/inc/AForm.hpp b/ex03/inc/AForm.hpp index 811c77c..6ddac11 100644 --- a/ex03/inc/AForm.hpp +++ b/ex03/inc/AForm.hpp @@ -15,11 +15,21 @@ class AForm const int _executeGrade; public: + // Constructors AForm() = delete; AForm(std::string name, int signGrade, int executeGrade); + + // Copy constructor and copy assignment operator AForm(const AForm &other); + AForm &operator=(const AForm &other) = delete; + + // Move constructor and move assignment operator + AForm(AForm &&other) noexcept; + AForm &operator=(AForm &&other) noexcept = delete; + + // Destructor virtual ~AForm(); - AForm &operator=(const AForm &other) = delete; + const std::string &getName() const; bool getIsSigned() const; int getSignGrade() const; diff --git a/ex03/inc/Bureaucrat.hpp b/ex03/inc/Bureaucrat.hpp index 8b2f6eb..0103b6b 100644 --- a/ex03/inc/Bureaucrat.hpp +++ b/ex03/inc/Bureaucrat.hpp @@ -14,12 +14,20 @@ class Bureaucrat int _grade; public: + // Constructors Bureaucrat() = delete; Bureaucrat(std::string name, int grade); - Bureaucrat(Bureaucrat &other); - ~Bureaucrat(); - Bureaucrat &operator=(Bureaucrat &other) = delete; + // Copy constructor and copy assignment operator + Bureaucrat(const Bureaucrat &other); + Bureaucrat &operator=(const Bureaucrat &other) = delete; + + // Move constructor and move assignment operator + Bureaucrat(Bureaucrat &&other) noexcept; + Bureaucrat &operator=(Bureaucrat &&other) noexcept = delete; + + // Destructor + ~Bureaucrat(); Bureaucrat &operator++(); // Pre-increment Bureaucrat operator++(int); // Post-increment @@ -29,14 +37,17 @@ class Bureaucrat int getGrade() const; const std::string getName() const; void signForm(class AForm &form); + void executeForm(const class AForm &form) const; class GradeTooHighException : public std::exception { + public: const char *what() const throw(); }; class GradeTooLowException : public std::exception { + public: const char *what() const throw(); }; }; diff --git a/ex03/inc/Intern.hpp b/ex03/inc/Intern.hpp index 986babd..e62e6d6 100644 --- a/ex03/inc/Intern.hpp +++ b/ex03/inc/Intern.hpp @@ -7,9 +7,18 @@ class Intern { public: + // Constructors Intern(); + + // Copy constructor and copy assignment operator Intern(const Intern &other); Intern &operator=(const Intern &other); + + // Move constructor and move assignment operator + Intern(Intern &&other) noexcept; + Intern &operator=(Intern &&other) noexcept; + + // Destructor ~Intern(); AForm *makeForm(const std::string &formName, const std::string &target); diff --git a/ex03/inc/PresidentialPardonForm.hpp b/ex03/inc/PresidentialPardonForm.hpp index 80e2b1f..13a5c44 100644 --- a/ex03/inc/PresidentialPardonForm.hpp +++ b/ex03/inc/PresidentialPardonForm.hpp @@ -11,13 +11,23 @@ class PresidentialPardonForm : public AForm const std::string _target; public: + // Constructors PresidentialPardonForm() = delete; PresidentialPardonForm(std::string target); + + // Copy constructor and copy assignment operator PresidentialPardonForm(const PresidentialPardonForm &other); - ~PresidentialPardonForm(); PresidentialPardonForm &operator=(const PresidentialPardonForm &other) = delete; + // Move constructor and move assignment operator + PresidentialPardonForm(PresidentialPardonForm &&other) noexcept; + PresidentialPardonForm &operator=(PresidentialPardonForm &&other) noexcept = + delete; + + // Destructor + ~PresidentialPardonForm(); + void execute(const Bureaucrat &executor) const override; const std::string getTarget() const; }; diff --git a/ex03/inc/RobotomyRequestForm.hpp b/ex03/inc/RobotomyRequestForm.hpp index d8edaf2..11e25d7 100644 --- a/ex03/inc/RobotomyRequestForm.hpp +++ b/ex03/inc/RobotomyRequestForm.hpp @@ -11,12 +11,22 @@ class RobotomyRequestForm : public AForm const std::string _target; public: + // Constructors RobotomyRequestForm() = delete; RobotomyRequestForm(std::string target); + + // Copy constructor and copy assignment operator RobotomyRequestForm(const RobotomyRequestForm &other); - ~RobotomyRequestForm(); RobotomyRequestForm &operator=(const RobotomyRequestForm &other) = delete; + // Move constructor and move assignment operator + RobotomyRequestForm(RobotomyRequestForm &&other) noexcept; + RobotomyRequestForm &operator=(RobotomyRequestForm &&other) noexcept = + delete; + + // Destructor + ~RobotomyRequestForm(); + void execute(const Bureaucrat &executor) const override; const std::string getTarget() const; }; diff --git a/ex03/inc/ShrubberyCreationForm.hpp b/ex03/inc/ShrubberyCreationForm.hpp index 98a6a6f..f0c4f5b 100644 --- a/ex03/inc/ShrubberyCreationForm.hpp +++ b/ex03/inc/ShrubberyCreationForm.hpp @@ -11,13 +11,23 @@ class ShrubberyCreationForm : public AForm const std::string _target; public: - ShrubberyCreationForm() = delete; // Default constructor is deleted + // Constructors + ShrubberyCreationForm() = delete; ShrubberyCreationForm(std::string target); + + // Copy constructor and copy assignment operator ShrubberyCreationForm(const ShrubberyCreationForm &other); - ~ShrubberyCreationForm(); ShrubberyCreationForm &operator=(const ShrubberyCreationForm &other) = delete; + // Move constructor and move assignment operator + ShrubberyCreationForm(ShrubberyCreationForm &&other) noexcept; + ShrubberyCreationForm &operator=(ShrubberyCreationForm &&other) noexcept = + delete; + + // Destructor + ~ShrubberyCreationForm(); + void execute(const Bureaucrat &executor) const override; const std::string getTarget() const; }; diff --git a/ex03/inc/colors.h b/ex03/inc/colors.h index 37189b0..240bcd1 100644 --- a/ex03/inc/colors.h +++ b/ex03/inc/colors.h @@ -1,25 +1,6 @@ #ifndef COLORS_H #define COLORS_H -#define BUREAUCRAT BOLD BACKGROUND4 " Bureaucrat: " RESET " " -#define INTERN BOLD BACKGROUND6 " Intern: " RESET " " -#define AFORM BOLD BACKGROUND5 " AForm: " RESET " " -#define SHRUBBERY_CREATION_FORM BOLD BACKGROUND10 " ShrubberyCreationForm: " RESET " " -#define ROBOTOMY_REQUEST_FORM BOLD BACKGROUND11 " RobotomyRequestForm: " RESET " " -#define PRESIDENTIAL_PARDON_FORM BOLD BACKGROUND8 " PresidentialPardonForm: " RESET " " - -#define CONSTRUCTOR "Constructor called" -#define PARAMETERIZED_CONSTRUCTOR "Parameterized constructor called" -#define ASSIGNMENT_OPERATOR "Assignment operator called" -#define DESTRUCTOR "Destructor called" -#define COPY_CONSTRUCTOR "Copy constructor called" - -#define EXCEPTION BOLD BACKGROUND9 " Exception: " RESET " " -#define INFO ITALIC BOLD UNDERLINE GREEN "Info: " -#define PRINT BOLD BACKGROUND7 " Print: " RESET " " -#define END_SCOPE ITALIC BOLD UNDERLINE RED "End of scope" RESET -#define END_SCOPE_EXCEPTION ITALIC BOLD UNDERLINE RED "End of scope with exception" RESET - #define RESET "\033[m" #define BOLD_UNDERLINE "\033[1;4m" @@ -82,4 +63,18 @@ #define BACKGROUND14 "\033[48;5;14m" #define BACKGROUND15 "\033[48;5;15m" -#endif +#define CONSTRUCTOR "Constructor called" +#define PARAMETERIZED_CONSTRUCTOR "Parameterized constructor called" +#define ASSIGNMENT_OPERATOR "Assignment operator called" +#define DESTRUCTOR "Destructor called" +#define COPY_CONSTRUCTOR "Copy constructor called" +#define MOVE_CONSTRUCTOR "Move constructor called" + +#define EXCEPTION BOLD BACKGROUND9 " Exception: " RESET " " +#define INFO ITALIC BOLD UNDERLINE GREEN "Info: " +#define PRINT BOLD BACKGROUND7 " Print: " RESET " " +#define END_SCOPE ITALIC BOLD UNDERLINE RED "End of scope" RESET +#define END_SCOPE_EXCEPTION \ + ITALIC BOLD UNDERLINE RED "End of scope with exception" RESET + +#endif \ No newline at end of file diff --git a/ex03/src/AForm.cpp b/ex03/src/AForm.cpp index e8bd619..275a487 100644 --- a/ex03/src/AForm.cpp +++ b/ex03/src/AForm.cpp @@ -5,6 +5,8 @@ #include "colors.h" +#define AFORM BOLD BACKGROUND5 " AForm: " RESET " " + AForm::AForm(std::string name, int signGrade, int executeGrade) : _name(name), _isSigned(false), @@ -29,6 +31,16 @@ AForm::AForm(const AForm &other) std::cout << AFORM << *this << std::endl; } +AForm::AForm(AForm &&other) noexcept + : _name(std::move(other._name)), + _isSigned(other._isSigned), + _signGrade(other._signGrade), + _executeGrade(other._executeGrade) +{ + std::cout << AFORM MOVE_CONSTRUCTOR << std::endl; + std::cout << AFORM << *this << std::endl; +} + AForm::~AForm() { std::cout << AFORM DESTRUCTOR << std::endl; diff --git a/ex03/src/Bureaucrat.cpp b/ex03/src/Bureaucrat.cpp index 5ed5eb7..60d4194 100644 --- a/ex03/src/Bureaucrat.cpp +++ b/ex03/src/Bureaucrat.cpp @@ -6,6 +6,8 @@ #include "colors.h" +#define BUREAUCRAT BOLD BACKGROUND4 " Bureaucrat: " RESET " " + Bureaucrat::Bureaucrat(std::string name, int grade) : _name(name) { std::cout << BUREAUCRAT PARAMETERIZED_CONSTRUCTOR << std::endl; @@ -17,13 +19,20 @@ Bureaucrat::Bureaucrat(std::string name, int grade) : _name(name) std::cout << BUREAUCRAT << *this << std::endl; } -Bureaucrat::Bureaucrat(Bureaucrat &other) +Bureaucrat::Bureaucrat(const Bureaucrat &other) : _name(other._name), _grade(other._grade) { std::cout << BUREAUCRAT COPY_CONSTRUCTOR << std::endl; std::cout << BUREAUCRAT << *this << std::endl; } +Bureaucrat::Bureaucrat(Bureaucrat &&other) noexcept + : _name(std::move(other._name)), _grade(other._grade) +{ + std::cout << BUREAUCRAT MOVE_CONSTRUCTOR << std::endl; + std::cout << BUREAUCRAT << *this << std::endl; +} + Bureaucrat::~Bureaucrat() { std::cout << BUREAUCRAT DESTRUCTOR << std::endl; @@ -84,6 +93,21 @@ void Bureaucrat::signForm(AForm &form) } } +void Bureaucrat::executeForm(const AForm &form) const +{ + try + { + form.execute(*this); + std::cout << BUREAUCRAT << _name << " executes " << form.getName() + << std::endl; + } + catch (std::exception &e) + { + std::cout << EXCEPTION << _name << " cannot execute " << form.getName() + << " because: " << e.what() << std::endl; + } +} + const char *Bureaucrat::GradeTooHighException::what() const throw() { return "Grade too high!"; @@ -96,7 +120,7 @@ const char *Bureaucrat::GradeTooLowException::what() const throw() std::ostream &operator<<(std::ostream &os, const Bureaucrat &bureaucrat) { - std::cout << bureaucrat.getName() << ", bureaucrat grade " - << bureaucrat.getGrade(); + os << bureaucrat.getName() << ", bureaucrat grade " << bureaucrat.getGrade() + << "."; return os; } diff --git a/ex03/src/Intern.cpp b/ex03/src/Intern.cpp index f2bb967..f028d57 100644 --- a/ex03/src/Intern.cpp +++ b/ex03/src/Intern.cpp @@ -9,6 +9,8 @@ #include "colors.h" +#define INTERN BOLD BACKGROUND6 " Intern: " RESET " " + Intern::Intern() { std::cout << INTERN CONSTRUCTOR << std::endl; @@ -20,6 +22,12 @@ Intern::Intern(const Intern &other) std::cout << INTERN COPY_CONSTRUCTOR << std::endl; } +Intern::Intern(Intern &&other) noexcept +{ + (void)other; + std::cout << INTERN MOVE_CONSTRUCTOR << std::endl; +} + Intern &Intern::operator=(const Intern &other) { if (this != &other) @@ -29,6 +37,15 @@ Intern &Intern::operator=(const Intern &other) return *this; } +Intern &Intern::operator=(Intern &&other) noexcept +{ + if (this != &other) + { + std::cout << INTERN ASSIGNMENT_OPERATOR << std::endl; + } + return *this; +} + Intern::~Intern() { std::cout << INTERN DESTRUCTOR << std::endl; @@ -61,7 +78,10 @@ AForm *Intern::makeForm(const std::string &formName, const std::string &target) for (int i = 0; i < 3; ++i) { if (formName == formTypeStrs[i]) + { + std::cout << INTERN << "Intern creates " << formName << " form." << std::endl; return formFactories[i](target); + } } std::cout << "Unknown form type: " << formName << std::endl; return nullptr; diff --git a/ex03/src/PresidentialPardonForm.cpp b/ex03/src/PresidentialPardonForm.cpp index 2c82e2c..1713f36 100644 --- a/ex03/src/PresidentialPardonForm.cpp +++ b/ex03/src/PresidentialPardonForm.cpp @@ -7,6 +7,9 @@ #include "colors.h" +#define PRESIDENTIAL_PARDON_FORM \ + BOLD BACKGROUND8 " PresidentialPardonForm: " RESET " " + PresidentialPardonForm::PresidentialPardonForm(std::string target) : AForm("Presidential Pardon", 25, 5), _target(target) { @@ -28,6 +31,14 @@ PresidentialPardonForm::PresidentialPardonForm( std::cout << PRESIDENTIAL_PARDON_FORM << *this << std::endl; } +PresidentialPardonForm::PresidentialPardonForm( + PresidentialPardonForm &&other) noexcept + : AForm(std::move(other)), _target(std::move(other._target)) +{ + std::cout << PRESIDENTIAL_PARDON_FORM MOVE_CONSTRUCTOR << std::endl; + std::cout << PRESIDENTIAL_PARDON_FORM << *this << std::endl; +} + std::ostream &operator<<(std::ostream &os, const PresidentialPardonForm &form) { os << form.getName() diff --git a/ex03/src/RobotomyRequestForm.cpp b/ex03/src/RobotomyRequestForm.cpp index 311d8fb..482067a 100644 --- a/ex03/src/RobotomyRequestForm.cpp +++ b/ex03/src/RobotomyRequestForm.cpp @@ -7,6 +7,9 @@ #include "colors.h" +#define ROBOTOMY_REQUEST_FORM \ + BOLD BACKGROUND11 " RobotomyRequestForm: " RESET " " + RobotomyRequestForm::RobotomyRequestForm(std::string target) : AForm("Robotomy Request", 72, 45), _target(target) { @@ -19,6 +22,12 @@ RobotomyRequestForm::RobotomyRequestForm(const RobotomyRequestForm &other) std::cout << ROBOTOMY_REQUEST_FORM COPY_CONSTRUCTOR << std::endl; } +RobotomyRequestForm::RobotomyRequestForm(RobotomyRequestForm &&other) noexcept + : AForm(std::move(other)), _target(std::move(other._target)) +{ + std::cout << ROBOTOMY_REQUEST_FORM MOVE_CONSTRUCTOR << std::endl; +} + RobotomyRequestForm::~RobotomyRequestForm() { std::cout << ROBOTOMY_REQUEST_FORM DESTRUCTOR << std::endl; diff --git a/ex03/src/ShrubberyCreationForm.cpp b/ex03/src/ShrubberyCreationForm.cpp index fa39240..1d3c91c 100644 --- a/ex03/src/ShrubberyCreationForm.cpp +++ b/ex03/src/ShrubberyCreationForm.cpp @@ -8,6 +8,9 @@ #include "colors.h" +#define SHRUBBERY_CREATION_FORM \ + BOLD BACKGROUND10 " ShrubberyCreationForm: " RESET " " + ShrubberyCreationForm::ShrubberyCreationForm(std::string target) : AForm("Shrubbery Creation", 145, 137), _target(target) { @@ -22,6 +25,14 @@ ShrubberyCreationForm::ShrubberyCreationForm(const ShrubberyCreationForm &other) std::cout << SHRUBBERY_CREATION_FORM << *this << std::endl; } +ShrubberyCreationForm::ShrubberyCreationForm( + ShrubberyCreationForm &&other) noexcept + : AForm(std::move(other)), _target(std::move(other._target)) +{ + std::cout << SHRUBBERY_CREATION_FORM MOVE_CONSTRUCTOR << std::endl; + std::cout << SHRUBBERY_CREATION_FORM << *this << std::endl; +} + ShrubberyCreationForm::~ShrubberyCreationForm() { std::cout << SHRUBBERY_CREATION_FORM DESTRUCTOR << std::endl; diff --git a/ex03/src/main.cpp b/ex03/src/main.cpp index 074498a..d52b798 100644 --- a/ex03/src/main.cpp +++ b/ex03/src/main.cpp @@ -1,19 +1,18 @@ #include #include +#include "AForm.hpp" #include "Bureaucrat.hpp" #include "Intern.hpp" -#include "AForm.hpp" - #include "colors.h" - int main(void) { - Intern intern; - std::string forms[] = {"shrubbery creation", "robotomy request", "presidential pardon", "unknown"}; - Bureaucrat bureaucrat("Alice", 50); + Intern intern; + std::string forms[] = {"shrubbery creation", "robotomy request", + "presidential pardon", "unknown"}; + Bureaucrat bureaucrat("Alice", 50); for (const std::string &formName : forms) { std::cout << INFO << "Creating form: " << formName << std::endl; @@ -21,11 +20,13 @@ int main(void) if (form) { std::cout << "Created form: " << *form << std::endl; - try { + try + { bureaucrat.signForm(*form); - form->execute(bureaucrat); - - } catch (const std::exception &e) { + bureaucrat.executeForm(*form); + } + catch (const std::exception &e) + { std::cerr << EXCEPTION << e.what() << std::endl; } delete form;