/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/24 13:16:27 by narnaud #+# #+# */ /* Updated: 2022/06/26 15:37:26 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #include "Bureaucrat.hpp" void try_to_create(std::string name, int grade) { try { Bureaucrat b(name, grade); } catch (std::exception &e) { cout << "Creation " << name << "(" << grade << "):\n\t" << e.what() << endl; } } void evolve(Bureaucrat &b) { try { b.incrGrade(); } catch (std::exception &e) { cout << "Evolve " << b << ":\n\t" << e.what() << endl; } } void dismiss(Bureaucrat &b) { try { b.decrGrade(); } catch (std::exception &e) { cout << "Dismiss " << b << ":\n\t" << e.what() << endl; } } int main(void) { Bureaucrat first("first", 1); Bureaucrat last("last", 150); // Bureaucrat trash("trash", 200); cout << first << endl; cout << last << endl; evolve(first); dismiss(last); dismiss(first); evolve(last); cout << first << endl; cout << last << endl; try_to_create("God", 0); try_to_create("Trash", 151); }