main.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* main.cpp :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2025/07/17 15:10:40 by bchanot #+# #+# */
  9. /* Updated: 2025/12/29 16:12:36 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "Bureaucrat.hpp"
  13. #include <iostream>
  14. #include <limits>
  15. int main( void ) {
  16. Bureaucrat* bob = new Bureaucrat("bob", 150);
  17. Bureaucrat* jimmy = new Bureaucrat("jimmy", 1);
  18. std::cout << *bob << std::endl;
  19. std::cout << *jimmy << std::endl;
  20. try
  21. {
  22. bob->incrementGrade();
  23. jimmy->incrementGrade();
  24. }
  25. catch (std::exception & e)
  26. {
  27. std::cout << "Exception " << e.what() << std::endl;
  28. }
  29. std::cout << *bob << std::endl;
  30. std::cout << *jimmy << std::endl;
  31. try
  32. {
  33. jimmy->decrementGrade();
  34. bob->decrementGrade();
  35. bob->decrementGrade();
  36. }
  37. catch (std::exception & e)
  38. {
  39. std::cout << "Exception " << e.what() << std::endl;
  40. }
  41. std::cout << *bob << std::endl;
  42. std::cout << *jimmy << std::endl;
  43. Bureaucrat* tooHigh;
  44. try
  45. {
  46. tooHigh = new Bureaucrat("TooHigh", 0);
  47. }
  48. catch (std::exception & e)
  49. {
  50. std::cout << "Exception : " << e.what() << std::endl;
  51. }
  52. Bureaucrat* tooLow;
  53. try
  54. {
  55. tooLow = new Bureaucrat("TooLow", 151);
  56. }
  57. catch (std::exception & e)
  58. {
  59. std::cout << "Exception : " << e.what() << std::endl;
  60. }
  61. (void)tooLow;
  62. (void)tooHigh;
  63. delete (bob);
  64. delete (jimmy);
  65. return (0);
  66. }