-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShrubberyCreationForm.cpp
More file actions
64 lines (52 loc) · 2.63 KB
/
ShrubberyCreationForm.cpp
File metadata and controls
64 lines (52 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ShrubberyCreationForm.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zelhajou <zelhajou@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/26 13:15:21 by zelhajou #+# #+# */
/* Updated: 2024/12/30 16:20:03 by zelhajou ### ########.fr */
/* */
/* ************************************************************************** */
#include "ShrubberyCreationForm.hpp"
ShrubberyCreationForm::ShrubberyCreationForm() : AForm("ShrubberyCreation", 145, 137), _target("default") {}
ShrubberyCreationForm::ShrubberyCreationForm(const std::string &target) : AForm("ShrubberyCreation", 145, 137), _target(target) {}
ShrubberyCreationForm::ShrubberyCreationForm(const ShrubberyCreationForm &src) : AForm(src), _target(src._target) {}
ShrubberyCreationForm::~ShrubberyCreationForm() {}
ShrubberyCreationForm &ShrubberyCreationForm::operator=(const ShrubberyCreationForm &src)
{
if (this != &src)
AForm::operator=(src);
return *this;
}
void ShrubberyCreationForm::execute(Bureaucrat const &executor) const
{
checkExecution(executor);
std::string filename = _target + "_shrubbery";
std::ofstream outFile(filename.c_str());
if (!outFile.is_open())
throw FileOpenException();
outFile << " v" << std::endl;
outFile << " >X<" << std::endl;
outFile << " A" << std::endl;
outFile << " d$b" << std::endl;
outFile << " .d\\$$b." << std::endl;
outFile << " .d$i$$\\$$b." << std::endl;
outFile << " d$$@b" << std::endl;
outFile << " d\\$$$ib" << std::endl;
outFile << " .d$$$\\$$$b" << std::endl;
outFile << " .d$$@$$$$\\$$ib." << std::endl;
outFile << " d$$i$$b" << std::endl;
outFile << " d\\$$$$@$b" << std::endl;
outFile << " .d$@$$\\$$$$$@b." << std::endl;
outFile << ".d$$$$i$$$\\$$$$$$b." << std::endl;
outFile << " ###" << std::endl;
outFile << " ###" << std::endl;
outFile << " ###" << std::endl;
outFile.close();
}
const char *ShrubberyCreationForm::FileOpenException::what() const throw()
{
return "Could not open file for writing";
}