Alarm Clock C/C++ Version

/*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
}


                
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值