ex02 finished

This commit is contained in:
2026-02-18 00:16:54 +01:00
parent c233d14af7
commit f96fb516ff
10 changed files with 314 additions and 10 deletions

View File

@@ -67,7 +67,7 @@ std::string ShrubberyCreationForm::getTarget() const
// Execute //
//////////////////
void ShrubberyCreationForm::execute(Bureaucrat const &executor)
void ShrubberyCreationForm::execute(Bureaucrat const &executor) const
{
if (!this->getIsSigned())
throw FormNotSignedException();
@@ -75,8 +75,16 @@ void ShrubberyCreationForm::execute(Bureaucrat const &executor)
throw AForm::GradeTooLowException();
// ShrubberyCreation form action...
std::string filename = this->target + "_shrubbery";
std::ofstream file(filename.c_str());
if (!file.is_open())
{
std::cerr << "Error: could not create file "
<< filename << std::endl;
return ;
}
file << " _-_\n";
file << " /~~ ~~\\\n";
@@ -88,6 +96,7 @@ void ShrubberyCreationForm::execute(Bureaucrat const &executor)
file << " _ - | | -_\n";
file << " // \\";
file.close();
}
//////////////////