From 452e6bfa7bb4bca75dc4659bf9d707101b411977 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Tue, 17 Nov 2020 19:02:35 +0100 Subject: Added cpp05/ex02 main, Added cpp05/ex03 --- cpp05/ex03/RobotomyRequestForm.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 cpp05/ex03/RobotomyRequestForm.cpp (limited to 'cpp05/ex03/RobotomyRequestForm.cpp') diff --git a/cpp05/ex03/RobotomyRequestForm.cpp b/cpp05/ex03/RobotomyRequestForm.cpp new file mode 100644 index 0000000..ed05d5f --- /dev/null +++ b/cpp05/ex03/RobotomyRequestForm.cpp @@ -0,0 +1,38 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* RobotomyRequestForm.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/19 13:45:45 by cacharle #+# #+# */ +/* Updated: 2020/11/17 17:20:03 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "RobotomyRequestForm.hpp" + +RobotomyRequestForm::RobotomyRequestForm(std::string const& target) + : Form("robotomy request", 72, 45), 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