From 331c3596660fed6c8b04fdfd0a89435ccffaaf20 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Tue, 17 Nov 2020 13:52:48 +0100 Subject: Fixing cpp05/ex00-02 --- cpp05/ex02/RobotomyRequestForm.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'cpp05/ex02/RobotomyRequestForm.cpp') diff --git a/cpp05/ex02/RobotomyRequestForm.cpp b/cpp05/ex02/RobotomyRequestForm.cpp index e69de29..113bcd1 100644 --- a/cpp05/ex02/RobotomyRequestForm.cpp +++ b/cpp05/ex02/RobotomyRequestForm.cpp @@ -0,0 +1,38 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* RobotomyRequestForm.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/19 13:45:45 by cacharle #+# #+# */ +/* Updated: 2020/11/17 13:27:05 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "RobotomyRequestForm.hpp" + +RobotomyRequestForm::RobotomyRequestForm(std::string const& target) + : Form("robotomy request", 145, 137), m_target(target) {} + +RobotomyRequestForm::RobotomyRequestForm(const RobotomyRequestForm& other) + : Form(other) { *this = other; } + +RobotomyRequestForm& RobotomyRequestForm::operator=(const RobotomyRequestForm& other) +{ + Form::operator=(other); + m_target = other.m_target; + return *this; +} + +RobotomyRequestForm::~RobotomyRequestForm() {} + +void RobotomyRequestForm::executeUnsafe() const +{ + if (rand() % 100 <= 50) + std::cout << m_target << " has successfully been robotomized" << std::endl; + else + std::cout << m_target << " couldn't be robotomized" << std::endl; +} + +RobotomyRequestForm::RobotomyRequestForm() : Form("", 0, 0) {} -- cgit