#include #include #include RobotomyRequestForm::RobotomyRequestForm() : AForm("RobotomyRequestForm", 72, 45), target("Marvin") { std::cout << "RobotomyRequestForm default constructor called" << std::endl; } RobotomyRequestForm::RobotomyRequestForm(const RobotomyRequestForm& other) : AForm(other), target(other.target) { std::cout << "RobotomyRequestForm copy constructor called" << std::endl; } RobotomyRequestForm::RobotomyRequestForm(const std::string& target) : AForm("RobotomyRequestForm", 72, 45), target(target) { std::cout << "RobotomyRequestForm (target) constructor called" << std::endl; } void RobotomyRequestForm::executeAction() const { static bool seeded = false; if (!seeded) { std::srand(static_cast(std::time(NULL))); seeded = true; } std::cout << "* Bzzzzzz... Whirrrrr... Vrrrrrrrr... *" << std::endl; if (std::rand() % 2) std::cout << target << " has been robotomized successfully" << std::endl; else std::cout << "The robotomy of " << target << " failed" << std::endl; } const std::string& RobotomyRequestForm::getTarget() const { return target; } RobotomyRequestForm& RobotomyRequestForm::operator=(const RobotomyRequestForm& other) { std::cout << "RobotomyRequestForm assignment operator called" << std::endl; if (this != &other) { AForm::operator=(other); target = other.target; } return *this; } RobotomyRequestForm::~RobotomyRequestForm() { std::cout << "RobotomyRequestForm destructor called" << std::endl; }