/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* AForm.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: aortigos 150 || gradeToExecute > 150) throw GradeTooLowException(); else if (gradeToSign < 1 || gradeToExecute < 1) throw GradeTooHighException(); //std::cout << "AForm constructor with params called" << std::endl; } AForm::AForm(const AForm &other) : name (other.getName()), isSigned(other.getIsSigned()), gradeToSign(other.getGradeToSign()), gradeToExecute(other.getGradeToExecute()) { //std::cout << "AForm copy constructor called" << std::endl; } AForm& AForm::operator=(const AForm &other) { if (this != &other) this->isSigned = other.getIsSigned(); //std::cout << "AForm copy assigment operator called" << std::endl; return (*this); } AForm::~AForm() { //std::cout << "Destructor called" } ////////////////// // Getters // ////////////////// std::string AForm::getName() const { return (this->name); } bool AForm::getIsSigned() const { return (this->isSigned); } int AForm::getGradeToSign() const { return (this->gradeToSign); } int AForm::getGradeToExecute() const { return (this->gradeToExecute); } ////////////////// // SignAForm // ////////////////// void AForm::beSigned(const Bureaucrat &br) { if (this->gradeToSign < br.getGrade()) throw GradeTooLowException(); this->isSigned = true; } ////////////////// // << // ////////////////// std::ostream& operator<<(std::ostream &os, const AForm &form) { std::string isItSigned; if (form.getIsSigned()) { isItSigned = " is signed."; } else { isItSigned = " is not signed."; } os << form.getName() << isItSigned; return (os); } ////////////////// // Excepciones // ////////////////// const char* AForm::GradeTooLowException::what() const throw() { return ("grade too low"); } const char* AForm::GradeTooHighException::what() const throw() { return ("grade too high"); }