Skip to content

Commit

Permalink
finished ex01
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatih Cil committed Sep 12, 2022
1 parent 8ba3672 commit 061ee93
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 48 deletions.
6 changes: 3 additions & 3 deletions CPP/cpp-module-05/ex00/Bureaucrat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: fcil <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/11 21:39:02 by fcil #+# #+# */
/* Updated: 2022/09/12 12:44:58 by fcil ### ########.fr */
/* Updated: 2022/09/12 13:59:01 by fcil ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -39,7 +39,7 @@ class Bureaucrat
class GradeTooHighException : public std::exception
{
public:
const char* what() const throw()
virtual const char* what() const throw()
{
return ("Grade is too High.");
}
Expand All @@ -48,7 +48,7 @@ class Bureaucrat
class GradeTooLowException : public std::exception
{
public:
const char* what() const throw()
virtual const char* what() const throw()
{
return ("Grade is too Low.");
}
Expand Down
4 changes: 2 additions & 2 deletions CPP/cpp-module-05/ex01/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 14:59:31 by fcil ### ########.fr */
/* Updated: 2022/09/12 15:15:06 by fcil ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -70,7 +70,7 @@ void Bureaucrat::signForm(Form &form)
if (form.getSignGrade() >= this->getGrade())
{
form.setSignedResult(true);
std::cout << "<" << this->getName() << "> signs <" <<
std::cout << "<" << this->getName() << "> signed <" <<
form.getName() << ">" << std::endl;
}
else
Expand Down
4 changes: 3 additions & 1 deletion CPP/cpp-module-05/ex01/Bureaucrat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: fcil <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/11 21:39:02 by fcil #+# #+# */
/* Updated: 2022/09/12 14:55:03 by fcil ### ########.fr */
/* Updated: 2022/09/12 15:02:49 by fcil ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -19,6 +19,8 @@
#define LOWEST 150
#define HIGHEST 1

class Form;

class Bureaucrat
{
private:
Expand Down
4 changes: 3 additions & 1 deletion CPP/cpp-module-05/ex01/Form.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
/* By: fcil <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/12 13:46:52 by fcil #+# #+# */
/* Updated: 2022/09/12 14:56:35 by fcil ### ########.fr */
/* Updated: 2022/09/12 15:02:31 by fcil ### ########.fr */
/* */
/* ************************************************************************** */

#pragma once

#include "Bureaucrat.hpp"

class Bureaucrat;

class Form
{
private:
Expand Down
72 changes: 31 additions & 41 deletions CPP/cpp-module-05/ex01/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,48 @@
/* By: fcil <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/12 11:42:20 by fcil #+# #+# */
/* Updated: 2022/09/12 13:06:26 by fcil ### ########.fr */
/* Updated: 2022/09/12 15:16:00 by fcil ### ########.fr */
/* */
/* ************************************************************************** */

#include "Bureaucrat.hpp"

int main(void)
{
try
{
Bureaucrat f("fatih", 4);
std::cout << f << std::endl;
}
catch(const Bureaucrat::GradeTooHighException &e)
{
std::cerr << e.what() << std::endl;
}
try
{
Bureaucrat a("abyerk", 200);
}
catch(const std::exception& e)
{
std::cerr << e.what() << std::endl;
}
try
{
Bureaucrat bureaucrat1("uwu", 1);
bureaucrat1.incrementGrade();
std::cout << bureaucrat1 << std::endl;
{
Form form1("Player Contract", 150, 150);
Bureaucrat bCrat1("Richarlison", 1);
form1.beSigned(bCrat1);
std::cout << "Welcome to the Club" << std::endl;
bCrat1.incrementGrade();
}
catch (Bureaucrat::GradeTooHighException &e)
{
std::cerr << e.what() << std::endl;
catch (std::exception &e)
{
std::cout << "About to print the exception" << std::endl;
std::cout << e.what() << std::endl;
}
catch (Bureaucrat::GradeTooLowException &e)
{
std::cerr << e.what() << std::endl;
}


std::cout << "<<<<<<<<<<<<>>>>>>>>>>>" << std::endl;
try
{
Bureaucrat bureaucrat2("blabla", 150);
bureaucrat2.decrementGrade();
std::cout << bureaucrat2 << std::endl;
}
catch (Bureaucrat::GradeTooHighException &e)
{
std::cerr << e.what() << std::endl;
{
Form form1("Drivers License", 1, 1);
std::cout << form1;
Bureaucrat bCrat1("Caitlyn Jenner", 150);
form1.beSigned(bCrat1);
}
catch (Bureaucrat::GradeTooLowException &e)
{
std::cerr << e.what() << std::endl;
catch (std::exception &e)
{
std::cout << "About to print the exception" << std::endl;
std::cout << e.what() << std::endl;
}
std::cout << "<<<<<<<<<<<<<>>>>>>>>>>>>>" << std::endl;
Form form1("uwu", 60, 60);
std::cout << form1;
Bureaucrat bCrat1("aa", 50);
Bureaucrat bCrat2("bb", 120);
bCrat1.signForm(form1);
std::cout << form1;
bCrat2.signForm(form1);
std::cout << "<<<<<<<<<<<<<>>>>>>>>>>>>>" << std::endl;
}

0 comments on commit 061ee93

Please sign in to comment.