55 lines
1.5 KiB
C++
55 lines
1.5 KiB
C++
#include "ShrubberyCreationForm.hpp"
|
||
#include <fstream>
|
||
#include <stdexcept>
|
||
#include <string>
|
||
|
||
ShrubberyCreationForm::ShrubberyCreationForm(void) : AForm("ShrubberyCreationForm", 145, 137) {
|
||
_log("➕", "ShrubberyCreationForm", "", "default constructor called");
|
||
}
|
||
|
||
ShrubberyCreationForm::ShrubberyCreationForm(const ShrubberyCreationForm &cpy) : AForm(cpy) {
|
||
_log("➕", "ShrubberyCreationForm", "", "copy constructor called");
|
||
if (this != &cpy)
|
||
*this = cpy;
|
||
}
|
||
|
||
ShrubberyCreationForm::ShrubberyCreationForm(std::string target) : AForm(target, 145, 137) {
|
||
_log("➕", "ShrubberyCreationForm", "", "target constructor called");
|
||
}
|
||
|
||
ShrubberyCreationForm::~ShrubberyCreationForm(void) {
|
||
_log("➖", "ShrubberyCreationForm", "", "destructor called");
|
||
}
|
||
|
||
ShrubberyCreationForm &ShrubberyCreationForm::operator=(const ShrubberyCreationForm &cpy) {
|
||
_log("➕", "ShrubberyCreationForm", "", "copy assignement constructor called");
|
||
(void) cpy;
|
||
return (*this);
|
||
}
|
||
|
||
void ShrubberyCreationForm::_exec(const Bureaucrat &b) const {
|
||
(void) b;
|
||
std::ofstream file;
|
||
|
||
file.open(std::string(this->getName() + "_shruberry").c_str());
|
||
if (!file.is_open())
|
||
throw std::runtime_error("Could not write to " + this->getName() +
|
||
"_shruberry");
|
||
|
||
file << " _-_\n"
|
||
" /~~ ~~\\\n"
|
||
" /~~ ~~\\\n"
|
||
"{ }\n"
|
||
" \\ _- -_ /\n"
|
||
" ~ \\ // ~\n"
|
||
"_- - | | _- _\n"
|
||
" _ - | | -_\n"
|
||
" // \\\n";
|
||
|
||
file.close();
|
||
|
||
std::cout << "ASCII tree created in : " + this->getName() + "_shruberry"
|
||
<< std::endl;
|
||
}
|
||
|