「✨」 feat: Ex00 finished
This commit is contained in:
57
ex00/Bureaucrat.cpp
Normal file
57
ex00/Bureaucrat.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Bureaucrat.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/12/23 13:59:45 by adjoly #+# #+# */
|
||||
/* Updated: 2025/03/08 20:00:23 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "Bureaucrat.hpp"
|
||||
|
||||
Bureaucrat &Bureaucrat::operator=(Bureaucrat const &cpy) {
|
||||
if (&cpy == this)
|
||||
return *this;
|
||||
_grade = cpy._grade;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Bureaucrat &Bureaucrat::operator++(void) {
|
||||
_grade--;
|
||||
if (_grade < MAXGRADE)
|
||||
throw GradeTooHighException();
|
||||
return *this;
|
||||
}
|
||||
|
||||
Bureaucrat &Bureaucrat::operator--(void) {
|
||||
_grade++;
|
||||
if (_grade > MINGRADE)
|
||||
throw GradeTooLowException();
|
||||
return *this;
|
||||
}
|
||||
|
||||
Bureaucrat Bureaucrat::operator++(int) {
|
||||
Bureaucrat old = *this;
|
||||
|
||||
_grade--;
|
||||
if (_grade < MAXGRADE)
|
||||
throw GradeTooHighException();
|
||||
return (old);
|
||||
}
|
||||
|
||||
Bureaucrat Bureaucrat::operator--(int) {
|
||||
Bureaucrat old = *this;
|
||||
|
||||
_grade++;
|
||||
if (_grade > MINGRADE)
|
||||
throw GradeTooLowException();
|
||||
return old;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, Bureaucrat &val) {
|
||||
os << val.getName() << ", bureaucrat grade " << (int)val.getGrade();
|
||||
return os;
|
||||
}
|
Reference in New Issue
Block a user