aboutsummaryrefslogtreecommitdiff
path: root/cpp05/ex02/ShrubberyCreationForm.cpp
blob: aa9d5a4242286869e083d4013098dc39291194c4 (plain)
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
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ShrubberyCreationForm.cpp                          :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: cacharle <me@cacharle.xyz>                 +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/10/19 13:45:45 by cacharle          #+#    #+#             */
/*   Updated: 2020/11/17 13:23:52 by cacharle         ###   ########.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 <<
        "              ##              "
        "             ####             "
        "            ######            "
        "          ##########          "
        "        ##############        "
        "       ######ntm#######       "
        "     ###################      "
        "    #####################     "
        "            |___|             ";
    file.close();
}

ShrubberyCreationForm::ShrubberyCreationForm() : Form("", 0, 0) {}