diff options
Diffstat (limited to 'cpp05/ex01/Form.cpp')
| -rw-r--r-- | cpp05/ex01/Form.cpp | 70 |
1 files changed, 32 insertions, 38 deletions
diff --git a/cpp05/ex01/Form.cpp b/cpp05/ex01/Form.cpp index 8aafc94..12b0a95 100644 --- a/cpp05/ex01/Form.cpp +++ b/cpp05/ex01/Form.cpp @@ -6,51 +6,44 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/14 19:26:39 by charles #+# #+# */ -/* Updated: 2020/04/14 19:39:21 by charles ### ########.fr */ +/* Updated: 2020/10/19 13:20:29 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include "Form.hpp" +Form::Form() + : m_name(""), + m_gradeSign(1), + m_gradeExecute(1) +{} + Form::Form(Form const& other) : m_name(other.m_name), + m_signed(other.m_signed), m_gradeSign(other.m_gradeSign), m_gradeExecute(other.m_gradeExecute) -{ - *this = other; -} +{} -void Form::operator=(Form const& other) +Form& Form::operator=(Form const& other) { m_signed = other.m_signed; + return *this; } -Form::~Form() -{} +Form::~Form() {} Form::Form(std::string const& name) - : m_name(name), m_signed(false), m_gradeSign(1), m_gradeExecute(1) + : m_name(name), + m_signed(false), + m_gradeSign(1), + m_gradeExecute(1) {} -std::string const& Form::getName() const -{ - return m_name; -} - -bool Form::getSigned() const -{ - return m_signed; -} - -int Form::getGradeSign() const -{ - return m_gradeSign; -} - -int Form::getGradeExecute() const -{ - return m_gradeExecute; -} +std::string const& Form::getName() const { return m_name; } +bool Form::getSigned() const { return m_signed; } +int Form::getGradeSign() const { return m_gradeSign; } +int Form::getGradeExecute() const { return m_gradeExecute; } void Form::beSigned(Bureaucrat const& b) { @@ -58,16 +51,21 @@ void Form::beSigned(Bureaucrat const& b) m_signed = true; } -Form::GradeTooHighException::GradeTooHighException() : std::exception() -{} +/////////////////////////////////////////////////////////////////////////////// +// Exceptions +/////////////////////////////////////////////////////////////////////////////// + +Form::GradeTooHighException::GradeTooHighException() : std::exception() {} Form::GradeTooHighException::GradeTooHighException(GradeTooHighException const& other) : std::exception(other) {} -void Form::GradeTooHighException::operator=(GradeTooHighException const& other) +Form::GradeTooHighException& +Form::GradeTooHighException::operator=(GradeTooHighException const& other) { std::exception::operator=(other); + return *this; } Form::GradeTooHighException::~GradeTooHighException() @@ -85,9 +83,11 @@ Form::GradeTooLowException::GradeTooLowException(GradeTooLowException const& oth : std::exception(other) {} -void Form::GradeTooLowException::operator=(GradeTooLowException const& other) +Form::GradeTooLowException& +Form::GradeTooLowException::operator=(GradeTooLowException const& other) { std::exception::operator=(other); + return *this; } Form::GradeTooLowException::~GradeTooLowException() @@ -101,14 +101,8 @@ char const* Form::GradeTooLowException::what() const throw() std::ostream& operator<<(std::ostream& out, Form const& f) { out << f.getName() << " is " - << (f.getSigned() ? "" : "not") << "signed and needs at least" + << (f.getSigned() ? "" : "not ") << "signed and needs at least" << f.getGradeSign() << " to be signed and " << f.getGradeExecute() << " to be executed" << std::endl; return out; } - -Form::Form() - : m_name(""), - m_gradeSign(1), - m_gradeExecute(1) -{} |
