class Time
{
private:
int hour;
int minute;
public:
Time (int =24, int = 01);
~Time();
void setTime(int,int);
void setHour(int);
void setMinute(int);
int getHour();
int getMinute();
int printTime();
};
Time::Time(int hour,int minute)
{
setTime(hour,minute);
}
void Time::setTime(int hour, int minute)
{
setHour(hour);
setMinute(minute);
}
void Time::setHour( int h)
{
if(h<=12)
{
hour = h-12;
}
if(h>12 && h<=24)
{
hour = h-12;
}
}
void Time::setMinute(int m)
{
minute = m;
}
int Time::getHour();
{
return hour;
}
int Time::getMinute()
{
return minute;
}
void Time::printTime()
{
if(hour <= 12 && hour >= 24)
{
cout<<hour<<":"<<minute<<" am"<<endl;
}
if(hour >= 12 && hour <= 24)
{
cout<<hour<<":"<<minute<<" pm"<<endl;
}
}
|