mirror of
https://github.com/Ladebeze66/cpp-partie-2.git
synced 2025-12-16 14:07:54 +01:00
59 lines
2.2 KiB
C++
59 lines
2.2 KiB
C++
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* PresidentialPardonForm.cpp :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2024/02/21 11:31:13 by fgras-ca #+# #+# */
|
|
/* Updated: 2024/02/25 13:29:09 by fgras-ca ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "PresidentialPardonForm.hpp"
|
|
|
|
PresidentialPardonForm::PresidentialPardonForm(const std::string& target)
|
|
: AForm("PresidentialPardonForm", 25, 5), target(target)
|
|
{
|
|
std::cout << GREEN << "PresidentialPardonForm constructed for target: " << target << RESET << std::endl;
|
|
}
|
|
|
|
PresidentialPardonForm::PresidentialPardonForm(const PresidentialPardonForm& other)
|
|
: AForm(other), target(other.target)
|
|
{
|
|
std::cout << "PresidentialPardonForm copy constructed for target: " << target << std::endl;
|
|
}
|
|
|
|
PresidentialPardonForm& PresidentialPardonForm::operator=(const PresidentialPardonForm& other)
|
|
{
|
|
if (this != &other)
|
|
{
|
|
AForm::operator=(other);
|
|
target = other.target;
|
|
std::cout << "PresidentialPardonForm assigned from another form for target: " << target << std::endl;
|
|
}
|
|
return (*this);
|
|
}
|
|
|
|
PresidentialPardonForm::~PresidentialPardonForm()
|
|
{
|
|
std::cout << RED << "PresidentialPardonForm destroyed for target: " << target << RESET << std::endl;
|
|
}
|
|
|
|
void PresidentialPardonForm::execute(Bureaucrat const &executor) const
|
|
{
|
|
if (!getIsSigned())
|
|
{
|
|
throw AForm::NotSignedException();
|
|
}
|
|
if (executor.getGrade() > getGradeRequiredToExecute())
|
|
{
|
|
throw AForm::GradeTooLowException();
|
|
}
|
|
std::cout << MAGENTA << getTarget() << " has been pardoned by Zaphod Beeblebrox.\n" << RESET << std::endl;
|
|
}
|
|
|
|
std::string PresidentialPardonForm::getTarget() const
|
|
{
|
|
return (target);
|
|
} |