aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp05/ex00/Bureaucrat.cpp7
-rw-r--r--cpp05/ex00/Bureaucrat.hpp6
-rw-r--r--cpp05/ex00/main.cpp5
-rw-r--r--cpp05/ex01/Bureaucrat.cpp11
-rw-r--r--cpp05/ex01/Bureaucrat.hpp8
-rw-r--r--cpp05/ex01/main.cpp12
-rw-r--r--cpp05/ex02/Bureaucrat.cpp15
-rw-r--r--cpp05/ex02/Bureaucrat.hpp11
-rw-r--r--cpp05/ex02/Form.hpp4
-rw-r--r--cpp05/ex02/PresidentialPardonForm.hpp4
-rw-r--r--cpp05/ex02/RobotomyRequestForm.cpp3
-rw-r--r--cpp05/ex02/RobotomyRequestForm.hpp4
-rw-r--r--cpp05/ex02/ShrubberyCreationForm.hpp4
-rw-r--r--cpp05/ex02/main.cpp6
-rw-r--r--cpp05/ex03/Bureaucrat.cpp15
-rw-r--r--cpp05/ex03/Bureaucrat.hpp11
-rw-r--r--cpp05/ex03/Form.hpp5
-rw-r--r--cpp05/ex03/Intern.cpp9
-rw-r--r--cpp05/ex03/Intern.hpp2
-rw-r--r--cpp05/ex03/PresidentialPardonForm.hpp4
-rw-r--r--cpp05/ex03/RobotomyRequestForm.cpp3
-rw-r--r--cpp05/ex03/RobotomyRequestForm.hpp4
-rw-r--r--cpp05/ex03/ShrubberyCreationForm.hpp4
-rw-r--r--cpp05/ex03/main.cpp9
-rw-r--r--subjects/cpp05.en.pdfbin1422487 -> 1422325 bytes
25 files changed, 88 insertions, 78 deletions
diff --git a/cpp05/ex00/Bureaucrat.cpp b/cpp05/ex00/Bureaucrat.cpp
index 927d467..3385089 100644
--- a/cpp05/ex00/Bureaucrat.cpp
+++ b/cpp05/ex00/Bureaucrat.cpp
@@ -6,17 +6,18 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 18:08:13 by charles #+# #+# */
-/* Updated: 2020/11/17 10:23:23 by cacharle ### ########.fr */
+/* Updated: 2020/12/12 11:35:48 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "Bureaucrat.hpp"
-Bureaucrat::Bureaucrat(Bureaucrat const& other) { *this = other; }
+Bureaucrat::Bureaucrat(Bureaucrat const& other)
+ : m_name(other.m_name) { *this = other; }
Bureaucrat& Bureaucrat::operator=(Bureaucrat const& other)
{
- m_name = other.m_name;
+ // cannot copy other.m_name since it's constant
m_grade = other.m_grade;
return *this;
}
diff --git a/cpp05/ex00/Bureaucrat.hpp b/cpp05/ex00/Bureaucrat.hpp
index 222d219..1d0c076 100644
--- a/cpp05/ex00/Bureaucrat.hpp
+++ b/cpp05/ex00/Bureaucrat.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 18:04:32 by charles #+# #+# */
-/* Updated: 2020/11/17 10:28:41 by cacharle ### ########.fr */
+/* Updated: 2020/12/12 11:34:29 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -34,8 +34,8 @@ private:
Bureaucrat();
void checkGrade();
- std::string m_name;
- int m_grade;
+ std::string const m_name;
+ int m_grade;
class GradeTooHighException : public std::exception
{
diff --git a/cpp05/ex00/main.cpp b/cpp05/ex00/main.cpp
index 90092cf..e0b3edf 100644
--- a/cpp05/ex00/main.cpp
+++ b/cpp05/ex00/main.cpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 18:13:05 by charles #+# #+# */
-/* Updated: 2020/11/17 11:51:33 by cacharle ### ########.fr */
+/* Updated: 2020/12/12 11:41:15 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -22,13 +22,12 @@ int main()
Bureaucrat yep("YEP", 1);
Bureaucrat yep2(yep);
- Bureaucrat yep3("SHOULD NOT BE PRINTED", 42);
+ Bureaucrat yep3("SHOULD NOT BE OVERWRITTEN", 42);
yep3 = yep;
std::cout << yep;
std::cout << yep2;
std::cout << yep3;
-
std::cout << std::endl;
std::cout << "############### DECREMENT" << std::endl;
Bureaucrat a("jean", 140);
diff --git a/cpp05/ex01/Bureaucrat.cpp b/cpp05/ex01/Bureaucrat.cpp
index 1024d54..2c1dd46 100644
--- a/cpp05/ex01/Bureaucrat.cpp
+++ b/cpp05/ex01/Bureaucrat.cpp
@@ -6,17 +6,18 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 18:08:13 by charles #+# #+# */
-/* Updated: 2020/11/17 12:08:02 by cacharle ### ########.fr */
+/* Updated: 2020/12/12 11:58:39 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "Bureaucrat.hpp"
-Bureaucrat::Bureaucrat(Bureaucrat const& other) { *this = other; }
+Bureaucrat::Bureaucrat(Bureaucrat const& other)
+ : m_name(other.m_name) { *this = other; }
Bureaucrat& Bureaucrat::operator=(Bureaucrat const& other)
{
- m_name = other.m_name;
+ // m_name = other.m_name;
m_grade = other.m_grade;
return *this;
}
@@ -44,7 +45,7 @@ void Bureaucrat::decrementGrade()
checkGrade();
}
-void Bureaucrat::signForm(Form& form)
+void Bureaucrat::signForm(Form& form) const
{
try
{
@@ -53,7 +54,7 @@ void Bureaucrat::signForm(Form& form)
}
catch (std::exception &e)
{
- std::cout << m_name << " cannot sign " << form.getName() << " " << e.what() << std::endl;
+ std::cout << m_name << " cannot sign " << form.getName() << " because " << e.what() << std::endl;
}
}
diff --git a/cpp05/ex01/Bureaucrat.hpp b/cpp05/ex01/Bureaucrat.hpp
index 1886a76..3317021 100644
--- a/cpp05/ex01/Bureaucrat.hpp
+++ b/cpp05/ex01/Bureaucrat.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 18:04:32 by charles #+# #+# */
-/* Updated: 2020/11/17 11:32:12 by cacharle ### ########.fr */
+/* Updated: 2020/12/12 11:49:39 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -33,14 +33,14 @@ public:
void incrementGrade();
void decrementGrade();
- void signForm(Form& form);
+ void signForm(Form& form) const;
private:
Bureaucrat();
void checkGrade();
- std::string m_name;
- int m_grade;
+ std::string const m_name;
+ int m_grade;
class GradeTooHighException : public std::exception
{
diff --git a/cpp05/ex01/main.cpp b/cpp05/ex01/main.cpp
index 3200b0f..75091f3 100644
--- a/cpp05/ex01/main.cpp
+++ b/cpp05/ex01/main.cpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 18:13:05 by charles #+# #+# */
-/* Updated: 2020/11/17 12:10:38 by cacharle ### ########.fr */
+/* Updated: 2020/12/12 11:56:20 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -24,7 +24,7 @@ int main()
Bureaucrat yep("YEP", 1);
Bureaucrat yep2(yep);
- Bureaucrat yep3("SHOULD NOT BE PRINTED", 42);
+ Bureaucrat yep3("SHOULD NOT BE OVERWRITTEN", 42);
yep3 = yep;
std::cout << yep;
std::cout << yep2;
@@ -64,10 +64,10 @@ int main()
Bureaucrat c("baraucrat", 10);
std::cout << "############### SIGN FORM" << std::endl;
- Form f4("foo", 150, 1); c.signForm(f4);
- Form f3("foo", 10, 1); c.signForm(f3);
- Form f2("foo", 9, 1); c.signForm(f2);
- Form f1("foo", 1, 1); c.signForm(f1);
+ Form f4("foo1", 150, 1); c.signForm(f4);
+ Form f3("foo2", 10, 1); c.signForm(f3);
+ Form f2("foo3", 9, 1); c.signForm(f2);
+ Form f1("foo4", 1, 1); c.signForm(f1);
}
std::cout << std::endl;
diff --git a/cpp05/ex02/Bureaucrat.cpp b/cpp05/ex02/Bureaucrat.cpp
index 64bbd25..3b03186 100644
--- a/cpp05/ex02/Bureaucrat.cpp
+++ b/cpp05/ex02/Bureaucrat.cpp
@@ -6,17 +6,18 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 18:08:13 by charles #+# #+# */
-/* Updated: 2020/11/17 13:37:49 by cacharle ### ########.fr */
+/* Updated: 2020/12/12 12:15:30 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "Bureaucrat.hpp"
-Bureaucrat::Bureaucrat(Bureaucrat const& other) { *this = other; }
+Bureaucrat::Bureaucrat(Bureaucrat const& other)
+ : m_name(other.m_name) { *this = other; }
Bureaucrat& Bureaucrat::operator=(Bureaucrat const& other)
{
- m_name = other.m_name;
+ // m_name = other.m_name;
m_grade = other.m_grade;
return *this;
}
@@ -44,7 +45,7 @@ void Bureaucrat::decrementGrade()
checkGrade();
}
-void Bureaucrat::signForm(Form& form)
+void Bureaucrat::signForm(Form& form) const
{
try
{
@@ -53,11 +54,11 @@ void Bureaucrat::signForm(Form& form)
}
catch (std::exception &e)
{
- std::cout << m_name << " cannot sign " << form.getName() << " " << e.what() << std::endl;
+ std::cout << m_name << " cannot sign " << form.getName() << " because " << e.what() << std::endl;
}
}
-void Bureaucrat::executeForm(Form& form)
+void Bureaucrat::executeForm(Form const& form) const
{
try
{
@@ -66,7 +67,7 @@ void Bureaucrat::executeForm(Form& form)
}
catch (std::exception &e)
{
- std::cout << m_name << " cannot execute " << form.getName() << " " << e.what() << std::endl;
+ std::cout << m_name << " cannot execute " << form.getName() << " because " << e.what() << std::endl;
}
}
diff --git a/cpp05/ex02/Bureaucrat.hpp b/cpp05/ex02/Bureaucrat.hpp
index 8e44af0..01ca700 100644
--- a/cpp05/ex02/Bureaucrat.hpp
+++ b/cpp05/ex02/Bureaucrat.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 18:04:32 by charles #+# #+# */
-/* Updated: 2020/11/17 13:36:56 by cacharle ### ########.fr */
+/* Updated: 2020/12/12 12:14:57 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -33,16 +33,15 @@ public:
void incrementGrade();
void decrementGrade();
- void signForm(Form& form);
-
- void executeForm(Form& form);
+ void signForm(Form& form) const;
+ void executeForm(Form const& form) const;
private:
Bureaucrat();
void checkGrade();
- std::string m_name;
- int m_grade;
+ std::string const m_name;
+ int m_grade;
class GradeTooHighException : public std::exception
{
diff --git a/cpp05/ex02/Form.hpp b/cpp05/ex02/Form.hpp
index 78828da..9798331 100644
--- a/cpp05/ex02/Form.hpp
+++ b/cpp05/ex02/Form.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 19:19:45 by charles #+# #+# */
-/* Updated: 2020/11/17 17:09:15 by charles ### ########.fr */
+/* Updated: 2020/12/12 12:03:26 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -24,7 +24,7 @@ class Form
public:
Form(Form const& other);
Form& operator=(Form const& other);
- ~Form();
+ virtual ~Form();
Form(std::string const& name, int gradeSign, int gradeExecute);
diff --git a/cpp05/ex02/PresidentialPardonForm.hpp b/cpp05/ex02/PresidentialPardonForm.hpp
index fcf8a70..4a6c0a4 100644
--- a/cpp05/ex02/PresidentialPardonForm.hpp
+++ b/cpp05/ex02/PresidentialPardonForm.hpp
@@ -6,7 +6,7 @@
/* By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/19 13:42:46 by cacharle #+# #+# */
-/* Updated: 2020/11/17 17:02:03 by charles ### ########.fr */
+/* Updated: 2020/12/12 12:09:43 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -20,7 +20,7 @@ class PresidentialPardonForm : public Form
public:
PresidentialPardonForm(const PresidentialPardonForm& other);
PresidentialPardonForm& operator=(const PresidentialPardonForm& other);
- ~PresidentialPardonForm();
+ virtual ~PresidentialPardonForm();
PresidentialPardonForm(std::string const& target);
diff --git a/cpp05/ex02/RobotomyRequestForm.cpp b/cpp05/ex02/RobotomyRequestForm.cpp
index ed05d5f..85c18c8 100644
--- a/cpp05/ex02/RobotomyRequestForm.cpp
+++ b/cpp05/ex02/RobotomyRequestForm.cpp
@@ -6,7 +6,7 @@
/* By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/19 13:45:45 by cacharle #+# #+# */
-/* Updated: 2020/11/17 17:20:03 by charles ### ########.fr */
+/* Updated: 2020/12/12 12:08:26 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -29,6 +29,7 @@ RobotomyRequestForm::~RobotomyRequestForm() {}
void RobotomyRequestForm::executeUnsafe() const
{
+ std::cout << "DRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR" << std::endl;
if (rand() % 100 <= 50)
std::cout << m_target << " has successfully been robotomized" << std::endl;
else
diff --git a/cpp05/ex02/RobotomyRequestForm.hpp b/cpp05/ex02/RobotomyRequestForm.hpp
index a851b04..9032799 100644
--- a/cpp05/ex02/RobotomyRequestForm.hpp
+++ b/cpp05/ex02/RobotomyRequestForm.hpp
@@ -6,7 +6,7 @@
/* By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/19 13:43:37 by cacharle #+# #+# */
-/* Updated: 2020/11/17 13:27:32 by cacharle ### ########.fr */
+/* Updated: 2020/12/12 12:09:37 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -20,7 +20,7 @@ class RobotomyRequestForm : public Form
public:
RobotomyRequestForm(const RobotomyRequestForm& other);
RobotomyRequestForm& operator=(const RobotomyRequestForm& other);
- ~RobotomyRequestForm();
+ virtual ~RobotomyRequestForm();
RobotomyRequestForm(std::string const& target);
diff --git a/cpp05/ex02/ShrubberyCreationForm.hpp b/cpp05/ex02/ShrubberyCreationForm.hpp
index 4799d9d..7266eb8 100644
--- a/cpp05/ex02/ShrubberyCreationForm.hpp
+++ b/cpp05/ex02/ShrubberyCreationForm.hpp
@@ -6,7 +6,7 @@
/* By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/19 13:43:27 by cacharle #+# #+# */
-/* Updated: 2020/11/17 16:37:56 by charles ### ########.fr */
+/* Updated: 2020/12/12 12:09:51 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -24,7 +24,7 @@ class ShrubberyCreationForm : public Form
public:
ShrubberyCreationForm(const ShrubberyCreationForm& other);
ShrubberyCreationForm& operator=(const ShrubberyCreationForm& other);
- ~ShrubberyCreationForm();
+ virtual ~ShrubberyCreationForm();
ShrubberyCreationForm(std::string const& target);
diff --git a/cpp05/ex02/main.cpp b/cpp05/ex02/main.cpp
index 0f3a893..fe46a7a 100644
--- a/cpp05/ex02/main.cpp
+++ b/cpp05/ex02/main.cpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 18:13:05 by charles #+# #+# */
-/* Updated: 2020/11/17 17:50:20 by charles ### ########.fr */
+/* Updated: 2020/12/12 12:16:43 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -116,7 +116,7 @@ int main()
Bureaucrat c4("foo", 1); c4.executeForm(sh);
}
{
- std::cout << "############### PRESIDENTIAL SIGN FORM" << std::endl;
+ std::cout << "############### PRESIDENTIAL EXECUTE FORM" << std::endl;
PresidentialPardonForm pr("fu");
pr.beSigned(Bureaucrat("foo", 1));
Bureaucrat c1("foo", 150); c1.executeForm(pr);
@@ -125,7 +125,7 @@ int main()
Bureaucrat c4("foo", 1); c4.executeForm(pr);
}
{
- std::cout << "############### ROBOTOMY SIGN FORM" << std::endl;
+ std::cout << "############### ROBOTOMY EXECUTE FORM" << std::endl;
RobotomyRequestForm ro("mi");
ro.beSigned(Bureaucrat("foo", 1));
Bureaucrat c1("foo", 150); c1.executeForm(ro);
diff --git a/cpp05/ex03/Bureaucrat.cpp b/cpp05/ex03/Bureaucrat.cpp
index 64bbd25..7274f6b 100644
--- a/cpp05/ex03/Bureaucrat.cpp
+++ b/cpp05/ex03/Bureaucrat.cpp
@@ -6,17 +6,18 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 18:08:13 by charles #+# #+# */
-/* Updated: 2020/11/17 13:37:49 by cacharle ### ########.fr */
+/* Updated: 2020/12/12 12:21:27 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "Bureaucrat.hpp"
-Bureaucrat::Bureaucrat(Bureaucrat const& other) { *this = other; }
+Bureaucrat::Bureaucrat(Bureaucrat const& other)
+ : m_name(other.m_name) { *this = other; }
Bureaucrat& Bureaucrat::operator=(Bureaucrat const& other)
{
- m_name = other.m_name;
+ // m_name = other.m_name;
m_grade = other.m_grade;
return *this;
}
@@ -44,7 +45,7 @@ void Bureaucrat::decrementGrade()
checkGrade();
}
-void Bureaucrat::signForm(Form& form)
+void Bureaucrat::signForm(Form& form) const
{
try
{
@@ -53,11 +54,11 @@ void Bureaucrat::signForm(Form& form)
}
catch (std::exception &e)
{
- std::cout << m_name << " cannot sign " << form.getName() << " " << e.what() << std::endl;
+ std::cout << m_name << " cannot sign " << form.getName() << " because " << e.what() << std::endl;
}
}
-void Bureaucrat::executeForm(Form& form)
+void Bureaucrat::executeForm(Form const& form) const
{
try
{
@@ -66,7 +67,7 @@ void Bureaucrat::executeForm(Form& form)
}
catch (std::exception &e)
{
- std::cout << m_name << " cannot execute " << form.getName() << " " << e.what() << std::endl;
+ std::cout << m_name << " cannot execute " << form.getName() << " because " << e.what() << std::endl;
}
}
diff --git a/cpp05/ex03/Bureaucrat.hpp b/cpp05/ex03/Bureaucrat.hpp
index 8e44af0..1c7c565 100644
--- a/cpp05/ex03/Bureaucrat.hpp
+++ b/cpp05/ex03/Bureaucrat.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 18:04:32 by charles #+# #+# */
-/* Updated: 2020/11/17 13:36:56 by cacharle ### ########.fr */
+/* Updated: 2020/12/12 12:19:51 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -33,16 +33,15 @@ public:
void incrementGrade();
void decrementGrade();
- void signForm(Form& form);
-
- void executeForm(Form& form);
+ void signForm(Form& form) const;
+ void executeForm(Form const& form) const;
private:
Bureaucrat();
void checkGrade();
- std::string m_name;
- int m_grade;
+ std::string const m_name;
+ int m_grade;
class GradeTooHighException : public std::exception
{
diff --git a/cpp05/ex03/Form.hpp b/cpp05/ex03/Form.hpp
index 78828da..79e78fa 100644
--- a/cpp05/ex03/Form.hpp
+++ b/cpp05/ex03/Form.hpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 19:19:45 by charles #+# #+# */
-/* Updated: 2020/11/17 17:09:15 by charles ### ########.fr */
+/* Updated: 2020/12/12 12:20:25 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -24,7 +24,7 @@ class Form
public:
Form(Form const& other);
Form& operator=(Form const& other);
- ~Form();
+ virtual ~Form();
Form(std::string const& name, int gradeSign, int gradeExecute);
@@ -34,7 +34,6 @@ public:
int getGradeExecute() const;
void beSigned(Bureaucrat const& b);
-
void execute(Bureaucrat const& executor) const;
protected:
diff --git a/cpp05/ex03/Intern.cpp b/cpp05/ex03/Intern.cpp
index 3328957..b31c2b3 100644
--- a/cpp05/ex03/Intern.cpp
+++ b/cpp05/ex03/Intern.cpp
@@ -6,7 +6,7 @@
/* By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/17 13:41:09 by cacharle #+# #+# */
-/* Updated: 2020/11/17 18:08:56 by charles ### ########.fr */
+/* Updated: 2020/12/12 12:32:15 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -37,6 +37,11 @@ Form *Intern::makeForm(std::string const& name, std::string const& target)
{
for (size_t i = 0; i < sizeof(Intern::makeFormDispatch) / sizeof(Intern::makeFormEntry); i++)
if ((this->makeFormDispatch[i]).name == name)
- return (this->*(makeFormDispatch[i].func))(target);
+ {
+ Form *form = (this->*(makeFormDispatch[i].func))(target);
+ std::cout << "Intern creates " << *form;
+ return form;
+ }
+ std::cout << "Intern cannot create form: " << name << " is not a known form name" << std::endl;
return NULL;
}
diff --git a/cpp05/ex03/Intern.hpp b/cpp05/ex03/Intern.hpp
index c27874a..1565118 100644
--- a/cpp05/ex03/Intern.hpp
+++ b/cpp05/ex03/Intern.hpp
@@ -6,7 +6,7 @@
/* By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/17 13:39:59 by cacharle #+# #+# */
-/* Updated: 2020/11/17 17:58:02 by charles ### ########.fr */
+/* Updated: 2020/12/12 12:32:05 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
diff --git a/cpp05/ex03/PresidentialPardonForm.hpp b/cpp05/ex03/PresidentialPardonForm.hpp
index fcf8a70..36ab5ec 100644
--- a/cpp05/ex03/PresidentialPardonForm.hpp
+++ b/cpp05/ex03/PresidentialPardonForm.hpp
@@ -6,7 +6,7 @@
/* By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/19 13:42:46 by cacharle #+# #+# */
-/* Updated: 2020/11/17 17:02:03 by charles ### ########.fr */
+/* Updated: 2020/12/12 12:20:41 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -20,7 +20,7 @@ class PresidentialPardonForm : public Form
public:
PresidentialPardonForm(const PresidentialPardonForm& other);
PresidentialPardonForm& operator=(const PresidentialPardonForm& other);
- ~PresidentialPardonForm();
+ virtual ~PresidentialPardonForm();
PresidentialPardonForm(std::string const& target);
diff --git a/cpp05/ex03/RobotomyRequestForm.cpp b/cpp05/ex03/RobotomyRequestForm.cpp
index ed05d5f..6ac13e5 100644
--- a/cpp05/ex03/RobotomyRequestForm.cpp
+++ b/cpp05/ex03/RobotomyRequestForm.cpp
@@ -6,7 +6,7 @@
/* By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/19 13:45:45 by cacharle #+# #+# */
-/* Updated: 2020/11/17 17:20:03 by charles ### ########.fr */
+/* Updated: 2020/12/12 12:22:02 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -29,6 +29,7 @@ RobotomyRequestForm::~RobotomyRequestForm() {}
void RobotomyRequestForm::executeUnsafe() const
{
+ std::cout << "DRRRRRRRRRRRRRRRRRRRRRRRRRRRRR" << std::endl;
if (rand() % 100 <= 50)
std::cout << m_target << " has successfully been robotomized" << std::endl;
else
diff --git a/cpp05/ex03/RobotomyRequestForm.hpp b/cpp05/ex03/RobotomyRequestForm.hpp
index a851b04..f6cafd1 100644
--- a/cpp05/ex03/RobotomyRequestForm.hpp
+++ b/cpp05/ex03/RobotomyRequestForm.hpp
@@ -6,7 +6,7 @@
/* By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/19 13:43:37 by cacharle #+# #+# */
-/* Updated: 2020/11/17 13:27:32 by cacharle ### ########.fr */
+/* Updated: 2020/12/12 12:20:48 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -20,7 +20,7 @@ class RobotomyRequestForm : public Form
public:
RobotomyRequestForm(const RobotomyRequestForm& other);
RobotomyRequestForm& operator=(const RobotomyRequestForm& other);
- ~RobotomyRequestForm();
+ virtual ~RobotomyRequestForm();
RobotomyRequestForm(std::string const& target);
diff --git a/cpp05/ex03/ShrubberyCreationForm.hpp b/cpp05/ex03/ShrubberyCreationForm.hpp
index 4799d9d..27e34a0 100644
--- a/cpp05/ex03/ShrubberyCreationForm.hpp
+++ b/cpp05/ex03/ShrubberyCreationForm.hpp
@@ -6,7 +6,7 @@
/* By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/19 13:43:27 by cacharle #+# #+# */
-/* Updated: 2020/11/17 16:37:56 by charles ### ########.fr */
+/* Updated: 2020/12/12 12:20:33 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -24,7 +24,7 @@ class ShrubberyCreationForm : public Form
public:
ShrubberyCreationForm(const ShrubberyCreationForm& other);
ShrubberyCreationForm& operator=(const ShrubberyCreationForm& other);
- ~ShrubberyCreationForm();
+ virtual ~ShrubberyCreationForm();
ShrubberyCreationForm(std::string const& target);
diff --git a/cpp05/ex03/main.cpp b/cpp05/ex03/main.cpp
index aceb722..827071a 100644
--- a/cpp05/ex03/main.cpp
+++ b/cpp05/ex03/main.cpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 18:13:05 by charles #+# #+# */
-/* Updated: 2020/11/17 19:02:02 by charles ### ########.fr */
+/* Updated: 2020/12/12 12:32:41 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -117,7 +117,7 @@ int main()
Bureaucrat c4("foo", 1); c4.executeForm(sh);
}
{
- std::cout << "############### PRESIDENTIAL SIGN FORM" << std::endl;
+ std::cout << "############### PRESIDENTIAL EXECUTE FORM" << std::endl;
PresidentialPardonForm pr("fu");
pr.beSigned(Bureaucrat("foo", 1));
Bureaucrat c1("foo", 150); c1.executeForm(pr);
@@ -126,7 +126,7 @@ int main()
Bureaucrat c4("foo", 1); c4.executeForm(pr);
}
{
- std::cout << "############### ROBOTOMY SIGN FORM" << std::endl;
+ std::cout << "############### ROBOTOMY EXECUTE FORM" << std::endl;
RobotomyRequestForm ro("mi");
ro.beSigned(Bureaucrat("foo", 1));
Bureaucrat c1("foo", 150); c1.executeForm(ro);
@@ -250,6 +250,9 @@ int main()
std::cout << *sh;
std::cout << *pr;
std::cout << *ro;
+ delete sh;
+ delete pr;
+ delete ro;
}
return 0;
}
diff --git a/subjects/cpp05.en.pdf b/subjects/cpp05.en.pdf
index 2253f1c..ff16d34 100644
--- a/subjects/cpp05.en.pdf
+++ b/subjects/cpp05.en.pdf
Binary files differ