Advertisement
Guest User

ElementaryProblems

a guest
Mar 25th, 2013
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. DATE.CPP
  2.  
  3. #include "Date.h"
  4. string Date::setMonth(string month)
  5. {
  6. Date Date;
  7. transform(month.begin(),month.end(),month.begin(), toupper);
  8. cout << "Date.Month is:" << month << endl;
  9. if (month=="AUG"||month=="SEP"||month=="OCT"||month=="NOV"||month=="DEC"||month=="JAN"||month=="FEB"||month=="MAR"||month=="APR"||month=="MAY"||month=="JUN"||month=="JUL"){
  10. Date.month(month);
  11. return Date.month;
  12. }
  13. else{
  14. return Date.month("JAN");
  15. }
  16. }
  17. string Date::getMonth()
  18. {
  19. Date Date;
  20. return Date.month;
  21. }
  22. /*
  23. Date::Date()
  24. {
  25. Date Date;
  26. Date.year=0;
  27. Date.day=0;
  28. Date.month="";
  29. }
  30. Date::Date(int yr,int d,string mon)
  31. {
  32. Date Date;
  33. Date.year=yr;
  34. Date.day=d;
  35. Date.month=mon;
  36. }
  37. */
  38.  
  39. DATE.HPP
  40.  
  41. #include <iostream>
  42. #include <algorithm>
  43. #include <string>
  44. using namespace std;
  45. class Date
  46. {
  47. int year, day;
  48. string month;
  49. public:
  50. /*
  51. Date();
  52. Date(int year,int day,string mon);
  53. */
  54. static string Date::setMonth(string month);
  55. static string Date::getMonth();
  56. };
  57.  
  58. MAIN.CPP
  59.  
  60. #include "Date.h"
  61. int main()
  62. {
  63. Date Date;
  64. string month;
  65. cout << "Enter month:";
  66. cin >> month;
  67. Date.setMonth(month);
  68. cout << "Main calling getMonth():" << Date.getMonth() << endl;
  69. return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement