aboutsummaryrefslogtreecommitdiff
path: root/cpp05/ex03/ShrubberyCreationForm.cpp
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-11-17 19:02:35 +0100
committerCharles Cabergs <me@cacharle.xyz>2020-11-17 19:02:35 +0100
commit452e6bfa7bb4bca75dc4659bf9d707101b411977 (patch)
treef4ee27a96437d6d17a89bbbbc135ae45f9f3faae /cpp05/ex03/ShrubberyCreationForm.cpp
parenta92013c92bfcd50b0e2561280c9eaa604843ade0 (diff)
downloadpiscine_cpp-452e6bfa7bb4bca75dc4659bf9d707101b411977.tar.gz
piscine_cpp-452e6bfa7bb4bca75dc4659bf9d707101b411977.tar.bz2
piscine_cpp-452e6bfa7bb4bca75dc4659bf9d707101b411977.zip
Added cpp05/ex02 main, Added cpp05/ex03
Diffstat (limited to 'cpp05/ex03/ShrubberyCreationForm.cpp')
-rw-r--r--cpp05/ex03/ShrubberyCreationForm.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/cpp05/ex03/ShrubberyCreationForm.cpp b/cpp05/ex03/ShrubberyCreationForm.cpp
new file mode 100644
index 0000000..262f166
--- /dev/null
+++ b/cpp05/ex03/ShrubberyCreationForm.cpp
@@ -0,0 +1,51 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ShrubberyCreationForm.cpp :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/10/19 13:45:45 by cacharle #+# #+# */
+/* Updated: 2020/11/17 17:15:43 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "ShrubberyCreationForm.hpp"
+
+ShrubberyCreationForm::ShrubberyCreationForm(std::string const& target)
+ : Form("shrubbery creation", 145, 137), m_target(target) {}
+
+ShrubberyCreationForm::ShrubberyCreationForm(const ShrubberyCreationForm& other)
+ : Form(other) { *this = other; }
+
+ShrubberyCreationForm& ShrubberyCreationForm::operator=(const ShrubberyCreationForm& other)
+{
+ Form::operator=(other);
+ m_target = other.m_target;
+ return *this;
+}
+
+ShrubberyCreationForm::~ShrubberyCreationForm() {}
+
+void ShrubberyCreationForm::executeUnsafe() const
+{
+ std::ofstream file(m_target + "_shrubbery");
+ if (!file.is_open())
+ {
+ std::cerr << "Error: " << m_target + "_shrubbery" << ": " << std::strerror(errno) << std::endl;
+ return;
+ }
+ file <<
+ " ## \n"
+ " #### \n"
+ " ###### \n"
+ " ########## \n"
+ " ############## \n"
+ " ######ntm####### \n"
+ " ################### \n"
+ " ##################### \n"
+ " |___| \n";
+ file.close();
+}
+
+ShrubberyCreationForm::ShrubberyCreationForm() : Form("", 0, 0) {}