//Digital Clock+ Alarm clock +Stop watch through inheritance....
//I have Issue with Alarm clock/No idea about Alarm clock
//#include"stdafx.h"
#include<iostream>
#include<conio.h>
#include<Windows.h>
using namespace std;
int choice;
class clock{
protected:
int hours,minutes,seconds,out;
int A_hours,A_minutes,A_seconds;
int hors,minuts,secs;
public:
void getData()
{
cout<<"\t\t >>>>>>Please set the Time <<<<<"<<endl<<endl;
cout<<"Enter hours = ";
cin>>hours;
cout<<"Enter minutes = ";
cin>>minutes;
cout<<"Enter seconds = ";
cin>>seconds;
}
};
if(s==59)
{
seconds=00;
}
}//end of third for
if(m==59)
{
minutes=00;
}
}//end of second for
hours++;
if(hours==24)
hours=00;
}
}//end of first for
}//end of main if
else
cout<<"\nInvalid Time entered !!!! "<<endl<<endl<<endl;
}
};
class AlarmClock:public clock{
//protected:
public:
void AlarmClk()
{
}
};
class StopWatch: public clock{
public:
int ch,ch1;
void StWatch()
{
system("cls");
cout<<endl<<endl<<endl<<endl;
cout<<" (1) Press E to move back to main \n"
<<" (2) press S for stop the watch !\n"
<<" (3) press R for reset the watch !\n"
<<" (4) press any key for Resume watch !\n\n\n\n"<<endl<<endl<<endl<<endl;
cout<<hours<<":"<<minutes<<":"<<seconds<<":"<<milisec<<endl;
//Sleep(.0);
if (_kbhit())
{
ch = getch();
if ((ch == 'r')||(ch == 'R'))
{
seconds = 0;
minutes = 0;
hours = 0;
milisec=0;
}
else if (tolower(ch) == 's')
{
cout << "\t\t\t press any key for Resume\n";
ch1 = _getch();
}
else if (tolower(ch)=='e')
{
hours=23; //if i press E||e hrs,mnts,secs will go to thir max level i-e
minutes=59; //23,59,59 after whice for loop will be false and it will exit
seconds=59;
milisec=29;
system("cls");
}
}
}//end of mili
}//eND OF SEC LOOP
}//end of minute loop
}//end of hours loop
}
};
int main()
{
system("color f5");
do
{
cout<<">>>>Press 1 for Digital Clock == "<<endl;
cout<<">>>>Press 2 to Set Alarm Time == "<<endl;
cout<<">>>>Press 3 for the stop Watch == "<<endl<<endl<<endl;
cout<<"Please Enter your Choice = ";cin>>choice;
system("cls");