This project focuses on class inheritance, encapsulation, exception handling, and abstract base classes in C++
I implemented the Bureaucrat class with a constant name and a grade between 1 and 150. I enforced grade limits by throwing exceptions when the grade was too high or too low. I also added functions to increment and decrement the grade safely.
I created the Form class with attributes for name, signed status, and required grades to sign and execute. I implemented a method to allow a Bureaucrat to sign the form, throwing exceptions if the grade was insufficient, and I added output to show signing results.
I designed an abstract base class AForm and derived concrete forms ShrubberyCreationForm, RobotomyRequestForm, and PresidentialPardonForm. Each form implemented specific execution behaviors, checking if signed and if the executor’s grade was adequate, throwing exceptions otherwise.
I implemented the Intern class to create different types of forms based on a given name and target. The class defines three private helper methods—makeShrub, makeRobo, and makePresi—each instantiating a specific form type (ShrubberyCreationForm, RobotomyRequestForm, and PresidentialPardonForm respectively).
The makeForm method checks if the requested form name matches one of the known types, and if so, calls the corresponding creation method using a pointer-to-member-function array. If the name is valid, it creates the form, prints a confirmation message, and returns the new form pointer. Otherwise, it prints an error and returns nullptr.