Advertisement
Guest User

C+))

a guest
Dec 15th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4. class Date
  5. {
  6. private:
  7. int day;
  8. string Month;
  9. int Year;
  10. public:
  11. void Input_Date()
  12. {
  13. cout<<"Enter day\n";
  14. cin>>day;
  15. cout<<"Enter Month\n";
  16. cin>>Month;
  17. cout<<"Enter year\n";
  18. cin>>Year;
  19. try
  20. {
  21. if (day == 0)
  22. {
  23. throw 1;
  24. }
  25. if (Month==" ")
  26. {
  27. throw 2;
  28. }
  29. Year=sizeof(Year);
  30. if (Year<4)
  31. {
  32. throw 3;
  33. }
  34. }
  35. catch(int i)
  36. {
  37. if (i==1){
  38. cout << "Ошибка №" << i << " - значение дня должно быть больше 0!" << endl;}
  39. if (i==2)
  40. {
  41. cout << "Ошибка №" << i << " - название месяца должно быть строкой,а не числовым значением!" << endl;
  42. }
  43. if (i==3)
  44. {
  45. cout << "Ошибка №" << i << " - значение должно иметь в себе больше 3 символов!" << endl;
  46. }
  47. }
  48. }
  49. };
  50.  
  51.  
  52. int main() {
  53. Date d1;
  54. d1.Input_Date();
  55.  
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement