/ CPP_Modules / CPP_Module_05 / ex03 / Intern.cpp
Intern.cpp
 1  /* ************************************************************************** */
 2  /*                                                                            */
 3  /*                                                        :::      ::::::::   */
 4  /*   Intern.cpp                                         :+:      :+:    :+:   */
 5  /*                                                    +:+ +:+         +:+     */
 6  /*   By: gychoi <gychoi@student.42seoul.kr>         +#+  +:+       +#+        */
 7  /*                                                +#+#+#+#+#+   +#+           */
 8  /*   Created: 2023/12/04 00:22:42 by gychoi            #+#    #+#             */
 9  /*   Updated: 2023/12/04 16:26:05 by gychoi           ###   ########.fr       */
10  /*                                                                            */
11  /* ************************************************************************** */
12  
13  #include "Intern.hpp"
14  
15  /* ************************************************************************** */
16  /*                          Constructor & Destructor                          */
17  /* ************************************************************************** */
18  
19  Intern::Intern()
20  {
21  	// nothing to do
22  }
23  
24  Intern::Intern(Intern const& target)
25  {
26  	(void)target;
27  	// nothing to do
28  }
29  
30  Intern&	Intern::operator=(Intern const& target)
31  {
32  	(void)target;
33  	return *this;
34  }
35  
36  Intern::~Intern()
37  {
38  	// nothing to do
39  }
40  
41  /* ************************************************************************** */
42  /*                           Public Member Function                           */
43  /* ************************************************************************** */
44  
45  AForm*	Intern::makeForm
46  (std::string const& formName, std::string const& targetName)
47  {
48  	std::string const	nameArray[3] = {"presidential pardon",
49  										"robotomy request",
50  										"shrubbery creation"};
51  	AForm*				form;
52  	std::size_t			index = 0;
53  
54  	while (nameArray[index].compare(formName) != 0 && index < Intern::FORM_SIZE)
55  	{
56  		index++;
57  	}
58  
59  	switch(index)
60  	{
61  		case Intern::PRESIDENTIAL_PARDON:
62  			form = new PresidentialPardonForm(targetName);
63  			break;
64  		case Intern::ROBOTOMY_REQUEST:
65  			form = new RobotomyRequestForm(targetName);
66  			break;
67  		case Intern::SHRUBBERY_CREATION:
68  			form = new ShrubberyCreationForm(targetName);
69  			break;
70  		default:
71  			std::cout << "Intern can't find " << targetName << std::endl;
72  			return 0;
73  	}
74  
75  	std::cout << "Intern creates " << targetName << std::endl;
76  
77  	return form;
78  }