/ CPP_Modules / CPP_Module_05 / ex03 / bonus / 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/08 23:16:32 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  	if (this != &target)
33  	{
34  		(void)target;
35  	}
36  	return *this;
37  }
38  
39  Intern::~Intern()
40  {
41  	// nothing to do
42  }
43  
44  /* ************************************************************************** */
45  /*                           Public Member Function                           */
46  /* ************************************************************************** */
47  
48  AForm*	Intern::makeForm
49  (std::string const& formName, std::string const& targetName)
50  {
51  	std::string const	nameArray[3] = {"presidential pardon",
52  										"robotomy request",
53  										"shrubbery creation"};
54  	AForm*				form;
55  	std::size_t			index = 0;
56  
57  	while (nameArray[index].compare(formName) != 0 && index < Intern::FORM_SIZE)
58  	{
59  		index++;
60  	}
61  
62  	switch(index)
63  	{
64  		case Intern::PRESIDENTIAL_PARDON:
65  			form = new PresidentialPardonForm(targetName);
66  			break;
67  		case Intern::ROBOTOMY_REQUEST:
68  			form = new RobotomyRequestForm(targetName);
69  			break;
70  		case Intern::SHRUBBERY_CREATION:
71  			form = new ShrubberyCreationForm(targetName);
72  			break;
73  		default:
74  			std::cout << "Intern can't find " << targetName << std::endl;
75  			return 0;
76  	}
77  
78  	return form;
79  }