ex02 finished
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
//////////////////
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
# include <iostream>
|
||||
# include <fstream>
|
||||
# include <string>
|
||||
# include "../AForm/AForm.hpp"
|
||||
# include "../Bureaucrat/Bureaucrat.hpp"
|
||||
|
||||
class ShrubberyCreationForm : public AForm
|
||||
{
|
||||
@@ -33,7 +35,7 @@ class ShrubberyCreationForm : public AForm
|
||||
|
||||
std::string getTarget() const;
|
||||
|
||||
void execute(Bureaucrat const &executor);
|
||||
virtual void execute(Bureaucrat const &executor) const;
|
||||
|
||||
class FormNotSignedException : public std::exception {
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user