main.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 19:26:11 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "Bureaucrat.hpp"
  13. #include "Form.hpp"
  14. #include <iostream>
  15. #include <limits>
  16. int main( void ) {
  17. Bureaucrat* bob = new Bureaucrat("bob", 150);
  18. Bureaucrat* jimmy = new Bureaucrat("jimmy", 1);
  19. Form* form;
  20. try
  21. {
  22. form = new Form("B_24", 150, 80);
  23. }
  24. catch (std::exception & e)
  25. {
  26. std::cout << "Exception " << e.what() << std::endl;
  27. }
  28. try
  29. {
  30. form = new Form("B_23", 160, 70);
  31. }
  32. catch (std::exception & e)
  33. {
  34. std::cout << "Exception " << e.what() << std::endl;
  35. }
  36. try
  37. {
  38. form = new Form("B_22", 0, 70);
  39. }
  40. catch (std::exception & e)
  41. {
  42. std::cout << "Exception " << e.what() << std::endl;
  43. }
  44. try
  45. {
  46. form = new Form("B_21", 80, 0);
  47. }
  48. catch (std::exception & e)
  49. {
  50. std::cout << "Exception " << e.what() << std::endl;
  51. }
  52. try
  53. {
  54. form = new Form("B_20", 70, 151);
  55. }
  56. catch (std::exception & e)
  57. {
  58. std::cout << "Exception " << e.what() << std::endl;
  59. }
  60. std::cout << *form << std::endl;
  61. std::cout << *bob << std::endl;
  62. std::cout << *jimmy << std::endl;
  63. try
  64. {
  65. bob->incrementGrade();
  66. jimmy->incrementGrade();
  67. }
  68. catch (std::exception & e)
  69. {
  70. std::cout << "Exception " << e.what() << std::endl;
  71. }
  72. std::cout << *bob << std::endl;
  73. std::cout << *jimmy << std::endl;
  74. try
  75. {
  76. jimmy->decrementGrade();
  77. bob->decrementGrade();
  78. bob->decrementGrade();
  79. }
  80. catch (std::exception & e)
  81. {
  82. std::cout << "Exception " << e.what() << std::endl;
  83. }
  84. std::cout << *bob << std::endl;
  85. std::cout << *jimmy << std::endl;
  86. bob->signForm(*form);
  87. jimmy->signForm(*form);
  88. std::cout << *form << std::endl;
  89. delete (bob);
  90. delete (jimmy);
  91. delete(form);
  92. return (0);
  93. }