test.cpp file
#include "test.h"
#include <iostream.h>
Time::Time( int hr, int min, int sec)
{
hour = (hr >= 0 && hr < 24) ? hr : 0;
minute = (min >= 0 && min < 60) ? min : 0;
second = (sec >= 0 && sec < 60) ? sec : 0;
}
void Time::settime(int h, int m, int s)
{
hour = (h >= 0 && h < 24) ? h : 0;
minute = (m >= 0 && m < 60) ? m : 0;
second = (s >= 0 && s < 60) ? s : 0;
}
void Time::sethour(int h)
{hour = (h >= 0 && h < 24) ? h : 0;}
void Time::setmin(int m)
{minute = (m >= 0 && m < 60) ? m : 0;}
void Time::setsec(int s)
{second = (s >= 0 && s < 60) ? s : 0;}
int Time::gethour() const {return hour;}
int Time::getmin() const {return minute;}
int Time::getsec() const {return second;}
void Time::printmili() const
{
cout <<(hour < 10 ? "0" : "") << hour << ":"
<<(minute < 10 ? "0" : "") << minute << ":"
<<(second < 10 ? "0" : "") <<second;
}
void Time::printsta() const
{
cout << ((hour == 0 || hour== 12) ? 12 : hour % 12)<< ":"
<<(minute <10 ? "0" :"") << minute << ":"
<<(second < 10 ? "0":"") << second
<<(hour < 12 ? "AM" : "PM");
}
#include <iostream.h>
Time::Time( int hr, int min, int sec)
{
hour = (hr >= 0 && hr < 24) ? hr : 0;
minute = (min >= 0 && min < 60) ? min : 0;
second = (sec >= 0 && sec < 60) ? sec : 0;
}
void Time::settime(int h, int m, int s)
{
hour = (h >= 0 && h < 24) ? h : 0;
minute = (m >= 0 && m < 60) ? m : 0;
second = (s >= 0 && s < 60) ? s : 0;
}
void Time::sethour(int h)
{hour = (h >= 0 && h < 24) ? h : 0;}
void Time::setmin(int m)
{minute = (m >= 0 && m < 60) ? m : 0;}
void Time::setsec(int s)
{second = (s >= 0 && s < 60) ? s : 0;}
int Time::gethour() const {return hour;}
int Time::getmin() const {return minute;}
int Time::getsec() const {return second;}
void Time::printmili() const
{
cout <<(hour < 10 ? "0" : "") << hour << ":"
<<(minute < 10 ? "0" : "") << minute << ":"
<<(second < 10 ? "0" : "") <<second;
}
void Time::printsta() const
{
cout << ((hour == 0 || hour== 12) ? 12 : hour % 12)<< ":"
<<(minute <10 ? "0" :"") << minute << ":"
<<(second < 10 ? "0":"") << second
<<(hour < 12 ? "AM" : "PM");
}