#include
#include
Form::Form() : name("Vente"), isSigned(false), gradeToSign(150), gradeToExecute(150) {
std::cout << "Form default constructor called" << std::endl;
}
Form::Form(const Form& other) : name(other.name), isSigned(other.isSigned), gradeToSign(other.gradeToSign), gradeToExecute(other.gradeToExecute) {
std::cout << "Form copy constructor called" << std::endl;
}
Form::Form(const std::string& name) : name(name), isSigned(false), gradeToSign(150), gradeToExecute(150) {
std::cout << "Form (name) constructor called" << std::endl;
}
Form::Form(const std::string& name, const unsigned short gradeToSign, const unsigned short gradeToExecute) : name(name), isSigned(false), gradeToSign(gradeToSign), gradeToExecute(gradeToExecute) {
std::cout << "Form (name, gradeToSign, gradeToExecute) constructor called" << std::endl;
if (gradeToSign > 150 || gradeToExecute > 150)
throw GradeTooLowException();
if (gradeToSign < 1 || gradeToExecute < 1)
throw GradeTooHighException();
}
void Form::beSigned(Bureaucrat& bureaucrat) {
std::cout << "Be signed called" << std::endl;
if (bureaucrat.getGrade() > gradeToSign)
throw GradeTooLowException();
isSigned = true;
}
const std::string& Form::getName() const {
return name;
}
bool Form::getIsSigned() const {
return isSigned;
}
unsigned short Form::getGradeToSign() const {
return gradeToSign;
}
unsigned short Form::getGradeToExecute() const {
return gradeToExecute;
}
Form& Form::operator=(const Form& other) {
std::cout << "Form assignment operator called" << std::endl;
if (this != &other)
isSigned = other.isSigned;
return *this;
}
Form::~Form() {
std::cout << "Form destructor called" << std::endl;
}
std::ostream& operator<<(std::ostream& ostream, const Form& form) {
ostream << form.getName() << ", grade to sign " << form.getGradeToSign() << ", grade to execute " << form.getGradeToExecute() << ".";
return ostream;
}