Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include "Date.h"
  4. using K::Date;
  5. using std::cout;
  6. using std::cin;
  7. // Test program for Date class.
  8. // Provides user with an interface to call the different Date's public functions.
  9. int main()
  10. {
  11. // Variables for user input
  12. int menuChoice, inputMonth, inputDay, inputYear;
  13.  
  14. Date newDate;
  15. enum menuOptions
  16. {
  17. DATE_DEFAULT = 1,
  18. DATE,
  19. GET_MONTH,
  20. GET_DAY,
  21. GET_YEAR,
  22. DISPLAY,
  23. EXIT
  24. };
  25.  
  26. // Prompts user for an option #1-9, until 9 (Exit) is chosen.
  27. do
  28. {
  29. cout << "\n************************\n";
  30. cout << "*Date Class Tester Menu*\n";
  31. cout << "************************\n";
  32. cout << "1. Call Date()\n";
  33. cout << "2. Call Date(month, day, year)\n";
  34. cout << "3. Call getMonth()\n";
  35. cout << "4. Call getDay()\n";
  36. cout << "5. Call getYear()\n";
  37. cout << "6. Call display()\n";
  38. cout << "7. Exit\n";
  39. cin >> menuChoice;
  40.  
  41. switch (menuChoice)
  42. {
  43. case DATE_DEFAULT:
  44.  
  45. newDate = Date();
  46. break;
  47. case DATE:
  48. cout << "Date(month, day, year)\n";
  49. cout << "Enter month day year, separated by spaces: ";
  50. cin >> inputMonth >> inputDay >> inputYear;
  51. newDate = Date(inputMonth, inputDay, inputYear);
  52. break;
  53. case GET_MONTH:
  54. cout << "getMonth()\n";
  55. cout << "Month is " << newDate.getMonth() << "\n";
  56. break;
  57. case GET_DAY:
  58. cout << "getDay()\n";
  59. cout << "Day is " << newDate.getDay() << "\n";
  60. break;
  61. case GET_YEAR:
  62. cout << "getYear()\n";
  63. cout << "Year is " << newDate.getYear() << "\n";
  64. break;
  65. case DISPLAY:
  66. cout << "display()\n";
  67. newDate.display();
  68. break;
  69. case EXIT:
  70. cout << "Bye!\n";
  71. break;
  72. default:
  73. cout << "Invalid Option. Try again\n";
  74. }
  75. } while (menuChoice != EXIT);
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement