Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- //clockType class
- class clockType {
- private:
- int hours;
- int minutes;
- int seconds;
- public:
- clockType(int clockHrs = 00, int clockMins = 00, int clockSecs = 00);
- void setHours(int clockHrs);
- void setMinutes(int clockMins);
- void setSeconds(int clockSecs);
- void showTime();
- int getHours();
- int getMinutes();
- int getSeconds();
- };
- //constructor
- clockType::clockType(int clockHrs, int clockMins, int clockSecs)
- {
- hours = clockHrs;
- minutes = clockMins;
- seconds = clockSecs;
- };
- //functions
- void clockType::setHours(int clockHrs)
- {
- cout << "Please intput the Hours: \n";
- cin >> clockHrs;
- hours = clockHrs;
- };
- void clockType::setMinutes(int clockMins)
- {
- cout << "Please input the Minutes: \n ";
- cin >> clockMins;
- minutes = clockMins;
- };
- void clockType::setSeconds(int clockSecs)
- {
- cout << "Please input the Seconds: \n";
- cin >> clockSecs;
- seconds = clockSecs;
- };
- void clockType::showTime()
- {
- getHours();
- getMinutes();
- getSeconds();
- cout << "The current time is: " << hours << ':' << minutes << ':' << seconds << endl;
- };
- int clockType::getHours()
- {
- return hours;
- };
- int clockType::getMinutes()
- {
- return minutes;
- };
- int clockType::getSeconds()
- {
- return seconds;
- };
- void menu(clockType clockSettings)
- {
- int selection = 00;
- char answer;
- int clockHrs = 00;
- int clockMins = 00;
- int clockSecs = 00;
- cout << "Would you like to use the Clock Settings Program?(Y/N) \n";
- cin >> answer;
- while (answer == 'y' || answer == 'Y') {
- cout << "Please select from the following: \n";
- cout << "1. Show the current time.\n";
- cout << "2. Set the Hours.\n";
- cout << "3. Set the Minutes.\n";
- cout << "4. Set the Seconds.\n";
- cin >> selection;
- if (selection == 1)
- clockSettings.showTime();
- else if (selection == 2)
- clockSettings.setHours(clockHrs);
- else if (selection == 3)
- clockSettings.setMinutes(clockMins);
- else if (selection == 4)
- clockSettings.setSeconds(clockSecs);
- else
- cout << "Please enter a valid selection." << endl;
- }
- };
- //int main
- int main()
- {
- clockType clockSettings;
- menu(clockSettings);
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement