Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "Date.h"
- using K::Date;
- using std::cout;
- using std::cin;
- // Test program for Date class.
- // Provides user with an interface to call the different Date's public functions.
- int main()
- {
- // Variables for user input
- int menuChoice, inputMonth, inputDay, inputYear;
- Date newDate;
- enum menuOptions
- {
- DATE_DEFAULT = 1,
- DATE,
- GET_MONTH,
- GET_DAY,
- GET_YEAR,
- DISPLAY,
- EXIT
- };
- // Prompts user for an option #1-9, until 9 (Exit) is chosen.
- do
- {
- cout << "\n************************\n";
- cout << "*Date Class Tester Menu*\n";
- cout << "************************\n";
- cout << "1. Call Date()\n";
- cout << "2. Call Date(month, day, year)\n";
- cout << "3. Call getMonth()\n";
- cout << "4. Call getDay()\n";
- cout << "5. Call getYear()\n";
- cout << "6. Call display()\n";
- cout << "7. Exit\n";
- cin >> menuChoice;
- switch (menuChoice)
- {
- case DATE_DEFAULT:
- newDate = Date();
- break;
- case DATE:
- cout << "Date(month, day, year)\n";
- cout << "Enter month day year, separated by spaces: ";
- cin >> inputMonth >> inputDay >> inputYear;
- newDate = Date(inputMonth, inputDay, inputYear);
- break;
- case GET_MONTH:
- cout << "getMonth()\n";
- cout << "Month is " << newDate.getMonth() << "\n";
- break;
- case GET_DAY:
- cout << "getDay()\n";
- cout << "Day is " << newDate.getDay() << "\n";
- break;
- case GET_YEAR:
- cout << "getYear()\n";
- cout << "Year is " << newDate.getYear() << "\n";
- break;
- case DISPLAY:
- cout << "display()\n";
- newDate.display();
- break;
- case EXIT:
- cout << "Bye!\n";
- break;
- default:
- cout << "Invalid Option. Try again\n";
- }
- } while (menuChoice != EXIT);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement