Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #include "Date.h"
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. //int main()
  6.  
  7. Date::Date(int month,int day,int year)
  8. {
  9. this->month = month;
  10. this->day = day;
  11. this->year = year;
  12. }
  13.  
  14. bool Date::setMonth (int month)
  15. {
  16. if (month>0 && month<=12)
  17. {
  18. this-> month= month;
  19. return true;
  20. }
  21. else
  22. {
  23. return false;
  24. }
  25.  
  26.  
  27.  
  28. }
  29. bool Date::setYear(int year)
  30. {
  31. if (year>0)
  32. {
  33. this->year=year;
  34. return true;
  35. }
  36. else
  37. {
  38. return false;
  39. }
  40. }
  41. bool Date::setDay(int day)
  42. {
  43. if (day>0 && day<32)
  44. {
  45. this->day=day;
  46. return true;
  47. }
  48. else
  49. {
  50. return false;
  51. }
  52. }
  53. int Date::getMonth()
  54. {
  55. return month;
  56. }
  57. int Date::getYear()
  58. {
  59. return year;
  60. }
  61. int Date::getDay()
  62. {
  63. return day;
  64. }
  65. void Date::print(int type)
  66. {
  67. if (type==1)
  68. {
  69. cout<<month<<"/"<<day<<"/"<<year<<endl;
  70. }
  71. else if (type==2)
  72. {
  73. cout<<monthName[month-1]<<" "<<day<<","<<year<<endl;
  74. }
  75. else
  76. {
  77. cout<<day<<" "<<monthName[month-1]<<" "<<year<<endl;
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement