Macking Complete Clock with Stop Watch and Alarm Clock as well but no idea about Alarm clock

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

class digitalClock:public clock{
public:
void DigClock()
{
if((hours<=23) && (minutes<=59) && (seconds<=59))
{
{
for(int h=hours;h<=24;h++)
{

for(int m=minutes;m<=59;m++)
{

for(int s=seconds;s<=59;s++)
{

system("cls");
cout<<"\tDigital Clock "<<endl<<endl;
cout<<hours<<":"<<m<<":"<<s<<endl<<endl;
Sleep(1000);

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()
{

for(int hours=0;hours<24;hours++)
{
for(int minutes=0;minutes<60;minutes++)
{


for(int seconds=0;seconds<60;seconds++)
{
for(int milisec=0;milisec<30;milisec++)
{

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");

switch(choice)
{
case 1:
cout<<"\t\t\t\tDIGITAL CLOCK"<<endl<<endl;
digitalClock object;
object.getData();
object.DigClock();
break;

case 2:
cout<<"\t\t\t\tALARM CLOCK"<<endl<<endl;
AlarmClock obj;
obj.getData();
obj.AlarmClk();

break;

case 3:
cout<<"\t\t\t\tSTOPWATCH"<<endl<<endl;
StopWatch ob;
ob.getData();
ob.StWatch();

break;

default:
cout<<"Wrong/Invalide value entered !!!!! "<<endl<<endl<<endl;
}

}while(choice!=4);


system("pause");
return 0;
}
Last edited on
Topic archived. No new replies allowed.