Beispiel #1
1
Form::Form(std::string name, int sgrade, int xgrade): m_name(name), m_sgrade(sgrade), m_xgrade(xgrade), m_sign(0)
{
	if (m_sgrade > 150 || m_sgrade < 1)
		m_sgrade < 1 ? throw GradeTooHighException() : throw GradeTooLowException();
	if (m_xgrade > 150 || m_xgrade < 1)
		m_xgrade < 1 ? throw GradeTooHighException() : throw GradeTooLowException();	
	return;
}
Beispiel #2
1
void Bureaucrat::decreaseGrade(void)
{
	if (mn_grade + 1 > MIN_GRADE)
		throw GradeTooLowException();
	else
		mn_grade++;
}
Beispiel #3
0
Form::Form( std::string name, int signGrade, int executeGrade ) :
    _name(name), _signed(false), _signGrade(signGrade), _executeGrade(executeGrade)
{
    if (signGrade > 150)
        throw GradeTooLowException("grade required to sign the form is too low");
    else if (signGrade < 1)
        throw GradeTooHighException("grade required to sign the form is too high");
    if (executeGrade > 150)
        throw GradeTooLowException("grade required to execute the form is too low");
    else if (executeGrade < 1)
        throw GradeTooHighException("grade required to execute the form is too high");
}
Beispiel #4
0
void Form::checkGrade(int pn_grade) const
{
	if (pn_grade > MIN_GRADE)
		throw GradeTooLowException();
	if (pn_grade < MAX_GRADE)
		throw GradeTooHighException();
}
Beispiel #5
0
void		Bureaucrat::decGrade(void)
{
	if (m_grade + 1 > 150)
		throw GradeTooLowException();
	else
		m_grade += 1;
}
Beispiel #6
0
void				Form::beSigned(Bureaucrat const &b)
	throw(GradeTooLowException)
{
	if (b.getGrade() <= gradeSign)
		sign = true;
	else
		throw GradeTooLowException();
}
Beispiel #7
0
Form::Form(Form const &src) : name(src.name), sign(src.sign),
	gradeSign(src.gradeSign), gradeExec(src.gradeExec)
{
	if (gradeSign > 150 || gradeExec > 150)
		throw GradeTooLowException();
	else if (gradeSign < 1 || gradeExec < 1)
		throw GradeTooHighException();
}
Beispiel #8
0
void			Form::beSigned(Bureaucrat& b)
{
	if (b.getGrade() <= m_sgrade)
		m_sign = 1;
	else
		throw GradeTooLowException();
	return;
}
Beispiel #9
0
void				Form::execute(Bureaucrat const &b) const
	throw(GradeTooLowException)
{
	if (b.getGrade() <= gradeExec && sign)
		action();
	else
		throw GradeTooLowException();
}
Beispiel #10
0
void Form::beSigned(Bureaucrat &src) {
    if (src.getGrade() <= this->gradeSign) {
        this->validated = true;
    }
    else {
        throw GradeTooLowException();
    }
}
Beispiel #11
0
void Bureaucrat::decrementGrade() {
    if (this->grade + 1 > 150) {
        throw GradeTooLowException();
    }
    else {
        this->grade++;
    }
}
Beispiel #12
0
Bureaucrat::Bureaucrat(std::string const & p_name, int pn_grade) :
	m_name(p_name),
	mn_grade(pn_grade)
{
	if (pn_grade > MIN_GRADE)
		throw GradeTooLowException();
	if (pn_grade < MAX_GRADE)
		throw GradeTooHighException();
}
Beispiel #13
0
Form::Form(std::string name, int gradeSign, int gradeExec)
	throw(GradeTooLowException, GradeTooHighException) :
		name(name), sign(false), gradeSign(gradeSign), gradeExec(gradeExec)
{
	if (gradeSign > 150 || gradeExec > 150)
		throw GradeTooLowException();
	else if (gradeSign < 1 || gradeExec < 1)
		throw GradeTooHighException();
}
Beispiel #14
0
Bureaucrat::Bureaucrat(std::string name, short grade) : name(name) {
    if (grade < 0) {
        throw GradeTooHighException();
    }
    else if (grade > 150) {
        throw GradeTooLowException();
    }
    else
        this->grade = grade;
}
Beispiel #15
0
void            Form::beSigned( Bureaucrat const & b) {

    if (this->_signed == true) {
        std::cout << "form already signed" << std::endl;
        return;
        }
    if (b.getGrade() > this->_signGrade)
        throw GradeTooLowException("bureaucrat grade too low to sign the form");
    else
        this->_signed = true;
}
Beispiel #16
0
Form::Form(std::string name, short gradeSign, short gradeExecute)
        : name(name), gradeSign(gradeSign), gradeExecute(gradeExecute) {
    this->validated = false;
    try {
        if (gradeSign < 0 || gradeExecute < 0) {
            throw GradeTooHighException();
        }
        else if (gradeSign > 150 || gradeExecute > 150) {

            throw GradeTooLowException();
        }
    }
    catch (std::exception &e) {
        std::cerr << e.what() << std::endl;
    }
}
Beispiel #17
0
Bureaucrat::Bureaucrat(std::string name, int grade): m_name(name), m_grade(grade)
{
	if (m_grade > 150 || m_grade < 1)
		m_grade < 1 ? throw GradeTooHighException() : throw GradeTooLowException();
}