/*Alarm Clock Mp3 Player By JOHNATHAN BROWN (Legend28469)
Set a time.. when the System Time is the same as the time set
play an mp3
Date: Thursday, February 27, 2009 -- 12:00 am (EST Time)
Date: 2013 07 11 15:20 菜单号的选择处理是亮点
*/
#include <iostream> //Input output
#include <ctime> //To get the system time
#include <fstream> //If wishing to load a previous wake time
#include <string> //Hold the filename info
using namespace std;
//Global.. and Local
time_t s=time(NULL); //Getting ready for time
tm t=*localtime(&s); //Getting time put into Variable t
bool DisplayIntro() {
cout << "**********************************************\n";
cout << "****** LEGEND28469's Alarm Clock ********\n";
cout << "******************Version 1.0*****************\n";
cout << "Johnathan Brown Productions..\n\n";
//Not much to explain.. self explanatory
cout << "Instructions for use:\nPick an option in the menu.. Have Fun!!\n";
system("PAUSE"); //Wait for an enter
system("CLS"); //Clear screen
return true;
}
bool SetTime() { //Hold time in memory (to wake up)
system("CLS"); //Clear system screen
cout << "The Current Time is: " << t.tm_hour << ":" << t.tm_min;
cout << "\nIf this time is incorrect then please set your system time\n";
system("PAUSE"); //Give time to read
int hour; //HOLD the hour somewhere
int min; //HOLD the minute somewhere
string mp3; //Hold the name of the mp3 in here
cout << "\n\n\n"; //Clear a few lines
cout << "What hour would you like to wake up at [24 hr format]: ";
cin >> hour; //Put input into hour
cout << "\nWhat minute would you like to wake up at: ";
cin >> min; //Put input into min
cout << "\nPlease type the FULL path of the media file to open\nFor Example:";
cout << " C:\\cannon.mp3\n";
cout << "It must be in C: and no spaces allowed\n";
cout << "Please type it here --> ";
cin >> mp3;
cout << "\nInitializing Alarm Clock...\n";
cout << "Alarm Clock in progress... to wake you up at " << hour << ":" << min;
//Mp3 Info or whatever file type
loop: //Keep getting the time until everything adds up...
time_t s=time(0); //Getting ready for time
tm t=*localtime(&s); //Getting time put into Variable t
if (hour != t.tm_hour)
{
goto loop;
}
if (min != t.tm_min)
{
goto loop;
}
cout << "\nShowtime\n"; //Play the mp3
system(mp3.c_str()); //Play mp3
return true;
}
bool Retrieve() {
cout << "That feature hasn't been implemented yet.. sorry!!!\n";
system("pause");
return true;
}
int DisplayMenu() {
//Declare where the choice is going to go
int choice = 0;
/*While int choice is less than 1 (which it currently is),
or greater than 3 (in case they choose an option off the list)
Keep displaying the following
*/
while (choice < 1 || choice > 3) {
cout << "1) Set a time to wake up to" << endl; //Handle things in SetTime
cout << "2) Retrieve last used time to wake up to" << endl; //Handle things in Retrieve
cout << "3) Exit" << endl; //Exit the Program
cout << "What option would you like: ";
cin >> choice;
switch (choice)
{
case 1:
SetTime();
break;
case 2:
Retrieve();
break;
case 3:
return 0;
break;
default:
cout << "That is not a number between 1 and 3" << endl;
system("pause"); //In case number is outta range
system("cls");
break;
}
}
}
int main(int argc, char *argv[]) {
//Function Calls
DisplayIntro(); //Get the System Time
DisplayMenu(); //Display the menu.. and have the user make a choice
cout << "Thank you for using Legend28469's Alarm Clock\n\n";
system("PAUSE");
return EXIT_SUCCESS; //Or return 0
}
Alarm Clock C/C++ Version
最新推荐文章于 2021-10-16 12:27:34 发布