d05 ex02 ok
This commit is contained in:
47
d05/ex02/srcs/PresidentialPardonForm.cpp
Normal file
47
d05/ex02/srcs/PresidentialPardonForm.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "PresidentialPardonForm.hpp"
|
||||
|
||||
#define COPLIEN_COLOR B_CYAN
|
||||
|
||||
/*********************************************
|
||||
* CONSTRUCTORS
|
||||
*********************************************/
|
||||
|
||||
PresidentialPardonForm::PresidentialPardonForm( std::string target )
|
||||
: AForm("presidential_creation", target, 25, 5){
|
||||
std::cout << COPLIEN_COLOR "RobotomyRequestForm constructor" RESET "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
PresidentialPardonForm::PresidentialPardonForm( PresidentialPardonForm const & src )
|
||||
: AForm("presidential_creation", this->getTarget(), 25, 5) {
|
||||
std::cout << COPLIEN_COLOR "RobotomyRequestForm copy constructor" RESET "\n";
|
||||
*this = src;
|
||||
return;
|
||||
}
|
||||
|
||||
/*********************************************
|
||||
* DESTRUCTORS
|
||||
*********************************************/
|
||||
|
||||
PresidentialPardonForm::~PresidentialPardonForm() {
|
||||
std::cout << COPLIEN_COLOR "RobotomyRequestForm destructor" RESET "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
/*********************************************
|
||||
* OPERATORS
|
||||
*********************************************/
|
||||
|
||||
PresidentialPardonForm & PresidentialPardonForm::operator=( PresidentialPardonForm const & rhs ) {
|
||||
AForm::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*********************************************
|
||||
* PUBLIC MEMBER FUNCTIONS
|
||||
*********************************************/
|
||||
|
||||
void PresidentialPardonForm::formAction() const {
|
||||
std::cout << "Zaphod Beeblebrox pardon " << _target << "\n";
|
||||
}
|
||||
|
||||
51
d05/ex02/srcs/RobotomyRequestForm.cpp
Normal file
51
d05/ex02/srcs/RobotomyRequestForm.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include "RobotomyRequestForm.hpp"
|
||||
|
||||
#define COPLIEN_COLOR B_CYAN
|
||||
|
||||
/*********************************************
|
||||
* CONSTRUCTORS
|
||||
*********************************************/
|
||||
|
||||
RobotomyRequestForm::RobotomyRequestForm( std::string target )
|
||||
: AForm("robotomy_creation", target, 72, 45){
|
||||
std::cout << COPLIEN_COLOR "RobotomyRequestForm constructor" RESET "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
RobotomyRequestForm::RobotomyRequestForm( RobotomyRequestForm const & src )
|
||||
: AForm("robotomy_creation", this->getTarget(), 72, 45) {
|
||||
std::cout << COPLIEN_COLOR "RobotomyRequestForm copy constructor" RESET "\n";
|
||||
*this = src;
|
||||
return;
|
||||
}
|
||||
|
||||
/*********************************************
|
||||
* DESTRUCTORS
|
||||
*********************************************/
|
||||
|
||||
RobotomyRequestForm::~RobotomyRequestForm() {
|
||||
std::cout << COPLIEN_COLOR "RobotomyRequestForm destructor" RESET "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
/*********************************************
|
||||
* OPERATORS
|
||||
*********************************************/
|
||||
|
||||
RobotomyRequestForm & RobotomyRequestForm::operator=( RobotomyRequestForm const & rhs ) {
|
||||
AForm::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*********************************************
|
||||
* PUBLIC MEMBER FUNCTIONS
|
||||
*********************************************/
|
||||
|
||||
void RobotomyRequestForm::formAction() const {
|
||||
std::cout << "*drill sounds*\n";
|
||||
if (std::rand() % 2)
|
||||
std::cout << _target << " robotomized with success\n";
|
||||
else
|
||||
std::cout << _target << " robotomization failed\n";
|
||||
}
|
||||
|
||||
@@ -42,7 +42,8 @@ ShrubberyCreationForm & ShrubberyCreationForm::operator=( ShrubberyCreationForm
|
||||
*********************************************/
|
||||
|
||||
void ShrubberyCreationForm::formAction() const {
|
||||
std::ofstream ofs("Shrubbery.txt", std::ofstream::out);
|
||||
std::string name = _target + "_shrubbery";
|
||||
std::ofstream ofs(name.c_str(), std::ofstream::out);
|
||||
|
||||
if (!ofs)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user