diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-12-12 12:33:39 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-12-12 12:33:39 +0100 |
| commit | 0071b1e944cbce91ff6ff8e235280c3955ce1d5b (patch) | |
| tree | af908c41fc051002311f50e8f73b889769a5279e /cpp05/ex02 | |
| parent | c10aa969c60cedef893146307fa319250901465a (diff) | |
| download | piscine_cpp-0071b1e944cbce91ff6ff8e235280c3955ce1d5b.tar.gz piscine_cpp-0071b1e944cbce91ff6ff8e235280c3955ce1d5b.tar.bz2 piscine_cpp-0071b1e944cbce91ff6ff8e235280c3955ce1d5b.zip | |
Fixing cpp05 small errors
Diffstat (limited to 'cpp05/ex02')
| -rw-r--r-- | cpp05/ex02/Bureaucrat.cpp | 15 | ||||
| -rw-r--r-- | cpp05/ex02/Bureaucrat.hpp | 11 | ||||
| -rw-r--r-- | cpp05/ex02/Form.hpp | 4 | ||||
| -rw-r--r-- | cpp05/ex02/PresidentialPardonForm.hpp | 4 | ||||
| -rw-r--r-- | cpp05/ex02/RobotomyRequestForm.cpp | 3 | ||||
| -rw-r--r-- | cpp05/ex02/RobotomyRequestForm.hpp | 4 | ||||
| -rw-r--r-- | cpp05/ex02/ShrubberyCreationForm.hpp | 4 | ||||
| -rw-r--r-- | cpp05/ex02/main.cpp | 6 |
8 files changed, 26 insertions, 25 deletions
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); |
