feat: adding the finished ex03
This commit is contained in:
parent
b9c98dffda
commit
9771c8de4a
15 changed files with 965 additions and 0 deletions
68
cpp05/ex03/ShrubberyCreationForm.cpp
Normal file
68
cpp05/ex03/ShrubberyCreationForm.cpp
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ShrubberyCreationForm.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/18 18:05:02 by rparodi #+# #+# */
|
||||
/* Updated: 2025/03/19 15:52:44 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ShrubberyCreationForm.hpp"
|
||||
|
||||
ShrubberyCreationForm::ShrubberyCreationForm() : Form("ShrubberyCreationForm", SHRUB_SIGN_GRADE, SHRUB_EXEC_GRADE) {
|
||||
std::cout << "ShrubberyCreationForm default constructor" << std::endl;
|
||||
}
|
||||
|
||||
ShrubberyCreationForm::ShrubberyCreationForm(std::string target) : Form("ShrubberyCreationForm", SHRUB_SIGN_GRADE, SHRUB_EXEC_GRADE) {
|
||||
_target = target;
|
||||
std::cout << "ShrubberyCreationForm smart constructor" << std::endl;
|
||||
}
|
||||
|
||||
ShrubberyCreationForm::ShrubberyCreationForm(ShrubberyCreationForm const ©) : Form("ShrubberyCreationForm", SHRUB_SIGN_GRADE, SHRUB_EXEC_GRADE) {
|
||||
_target = copy.getTarget();
|
||||
*this = copy;
|
||||
std::cout << "ShrubberyCreationForm copy constructor" << std::endl;
|
||||
}
|
||||
|
||||
ShrubberyCreationForm& ShrubberyCreationForm::operator=( ShrubberyCreationForm const & assign )
|
||||
{
|
||||
std::cout << "Copy assignement operator called" << std::endl;
|
||||
setSign(assign.getSign());
|
||||
setExecute(assign.getExecute());
|
||||
return (*this);
|
||||
}
|
||||
|
||||
std::string ShrubberyCreationForm::getTarget() const {
|
||||
return _target;
|
||||
}
|
||||
|
||||
void ShrubberyCreationForm::execute(Bureaucrat const &executor) const {
|
||||
if (executor.getGrade() > this->getExecute()) {
|
||||
throw Form::GradeTooLowException();
|
||||
} else {
|
||||
std::string filename = this->getTarget() + "_shrubbery";
|
||||
std::fstream file(filename.c_str(), std::ios::out);
|
||||
file << \
|
||||
" _-_" << std::endl << \
|
||||
" /~~ ~~\\" << std::endl << \
|
||||
" /~~ ~~\\" << std::endl << \
|
||||
"{ }" << std::endl << \
|
||||
" \\ _- -_ /" << std::endl << \
|
||||
" ~ \\\\ // ~" << std::endl << \
|
||||
"_- - | | _- _" << std::endl << \
|
||||
" _ - | | -_" << std::endl << \
|
||||
" // \\\\" << std::endl << std::endl << \
|
||||
" _-_" << std::endl << \
|
||||
" /~~ ~~\\" << std::endl << \
|
||||
" /~~ ~~\\" << std::endl << \
|
||||
"{ }" << std::endl << \
|
||||
" \\ _- -_ /" << std::endl << \
|
||||
" ~ \\\\ // ~" << std::endl << \
|
||||
"_- - | | _- _" << std::endl << \
|
||||
" _ - | | -_" << std::endl << \
|
||||
" // \\\\" << std::endl << std::endl;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue