CPP05 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
ShrubberyCreationForm.cpp
[詳解]
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* ShrubberyCreationForm.cpp :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/06/30 12:13:15 by kamitsui #+# #+# */
9/* Updated: 2025/07/02 17:10:36 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
19
20ShrubberyCreationForm::ShrubberyCreationForm(const std::string &target)
21 : AForm("Shrubbery Creation", 145, 137, target) {}
22
23ShrubberyCreationForm::ShrubberyCreationForm(const ShrubberyCreationForm &other) : AForm(other) {}
24
29
31
36 std::string filename = getTarget() + "_shrubbery";
37 std::ofstream outfile(filename.c_str());
38
39 if (!outfile.is_open()) {
40 std::cerr << "Error: Could not open file " << filename << std::endl;
41 return;
42 }
43
44 // out each line of ASCII art
45 for (int i = 0; i < ASCII_ART_HEIGHT; ++i) {
46 outfile << ASCII_ART[i] << std::endl;
47 }
48
49 outfile.close();
50 std::cout << "Created shrubbery file at " << filename << std::endl;
51}
T c_str(T... args)
An abstract base class for forms.
Definition AForm.hpp:34
const std::string & getTarget() const
Definition AForm.cpp:46
AForm & operator=(const AForm &other)
Definition AForm.cpp:32
A concrete form that creates a file with ASCII trees.
ShrubberyCreationForm & operator=(const ShrubberyCreationForm &other)
virtual void performAction() const
Creates a file named "_target" + "_shrubbery" and writes ASCII trees to it.
T close(T... args)
T endl(T... args)
Defines the ShrubberyCreationForm class.
const char *const ASCII_ART[]
const int ASCII_ART_HEIGHT
T is_open(T... args)