Skip to content

Commit

Permalink
ex00: bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatih Cil committed Sep 12, 2022
1 parent 534e685 commit e9a43f7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
4 changes: 2 additions & 2 deletions CPP/cpp-module-05/ex00/Bureaucrat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: fcil <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/12 12:00:32 by fcil #+# #+# */
/* Updated: 2022/09/12 12:59:52 by fcil ### ########.fr */
/* Updated: 2022/09/12 13:05:12 by fcil ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -59,7 +59,7 @@ void Bureaucrat::incrementGrade()

void Bureaucrat::decrementGrade()
{
if (this->_grade + 1 < LOWEST)
if (this->_grade + 1 > LOWEST)
throw Bureaucrat::GradeTooLowException();
this->_grade++;

Expand Down
35 changes: 32 additions & 3 deletions CPP/cpp-module-05/ex00/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: fcil <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/12 11:42:20 by fcil #+# #+# */
/* Updated: 2022/09/12 13:01:50 by fcil ### ########.fr */
/* Updated: 2022/09/12 13:06:26 by fcil ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -16,7 +16,8 @@ int main(void)
{
try
{
Bureaucrat f("fatih", 0);
Bureaucrat f("fatih", 4);
std::cout << f << std::endl;
}
catch(const Bureaucrat::GradeTooHighException &e)
{
Expand All @@ -28,7 +29,35 @@ int main(void)
}
catch(const std::exception& e)
{
std::cout << "uwu";
std::cerr << e.what() << std::endl;
}
try
{
Bureaucrat bureaucrat1("uwu", 1);
bureaucrat1.incrementGrade();
std::cout << bureaucrat1 << std::endl;
}
catch (Bureaucrat::GradeTooHighException &e)
{
std::cerr << e.what() << std::endl;
}
catch (Bureaucrat::GradeTooLowException &e)
{
std::cerr << e.what() << std::endl;
}

try
{
Bureaucrat bureaucrat2("blabla", 150);
bureaucrat2.decrementGrade();
std::cout << bureaucrat2 << std::endl;
}
catch (Bureaucrat::GradeTooHighException &e)
{
std::cerr << e.what() << std::endl;
}
catch (Bureaucrat::GradeTooLowException &e)
{
std::cerr << e.what() << std::endl;
}
}

0 comments on commit e9a43f7

Please sign in to comment.