Time类
来源:百度文库 编辑:神马文学网 时间:2024/04/30 02:10:43
//page434客户主程序#include
#include "Time.h"
using namespace std;
void main()
{
Time time1(5,30,0);
Time time2;
int i;
cout<<"time1: ";
time1.Write();
cout<<" time2: ";
time2.Write();
cout< if(time1.Equal(time2))
cout<<"Times are equal"< else
cout<<"Times are NOT equal"< time2=time1;
cout<<"time1: ";
time1.Write();
cout<<" time2: ";
time2.Write();
cout< if(time1.Equal(time2))
cout<<"time are equal"< else
cout<<"time are NOT equal"< time2.Incrment();
cout<<"New time2: ";
time2.Write();
cout< if(time1.LessThan(time2))
cout<<"time1 is less than time2"< else
cout<<"time1 is NOT less than time2"< if(time2.LessThan(time1))
cout<<"time2 is less than time1"< else
cout<<"time2 is NOT less than time1"< time1.Set(23,59,55);
cout<<"Increment time1 from 23:59:55:"< for(i=1;i<=10;i++)
{
time1.Write();
cout<<' ';
time1.Incrment();
}
cout<}//time.hclass Time
{
private:
int hrs;
int mins;
int secs;
public:
void Set(int,int,int);
void Incrment();
void Write() const;
bool Equal(Time) const;
bool LessThan(Time) const;
Time(int,int,int);
Time();
};//time.cpp#include "Time.h"
#include
using namespace std;
void Time::Set(int hours,int minutes,int seconds)
{
hrs=hours;
mins=minutes;
secs=seconds;
}
void Time::Incrment()
{
secs++;
if(secs>59)
{
secs=0;
mins++;
if(mins>59)
{
mins=0;
hrs++;
if(hrs>23)
hrs=0;
}
}
}
void Time::Write()const
{
if(hrs<10)
cout<<'0';
cout< if(mins<10)
cout<<'0';
cout< if(secs<10)
cout<<'0';
cout<}
bool Time::Equal(Time otherTime)const
{
return (hrs==otherTime.hrs&&mins==otherTime.mins&&secs==otherTime.secs);
}
bool Time::LessThan(Time otherTime)const
{
return (hrs hrs==otherTime.hrs&&mins hrs==otherTime.hrs&&mins==otherTime.mins&&secs );
}
Time::Time(int hours,int minutes,int seconds)
{
hrs=hours;
mins=minutes;
secs=seconds;
}
Time::Time()
{
hrs=0;
mins=0;
secs=0;
}
#include "Time.h"
using namespace std;
void main()
{
Time time1(5,30,0);
Time time2;
int i;
cout<<"time1: ";
time1.Write();
cout<<" time2: ";
time2.Write();
cout<
cout<<"Times are equal"<
cout<<"Times are NOT equal"<
cout<<"time1: ";
time1.Write();
cout<<" time2: ";
time2.Write();
cout<
cout<<"time are equal"<
cout<<"time are NOT equal"<
cout<<"New time2: ";
time2.Write();
cout<
cout<<"time1 is less than time2"<
cout<<"time1 is NOT less than time2"<
cout<<"time2 is less than time1"<
cout<<"time2 is NOT less than time1"<
cout<<"Increment time1 from 23:59:55:"<
{
time1.Write();
cout<<' ';
time1.Incrment();
}
cout<
{
private:
int hrs;
int mins;
int secs;
public:
void Set(int,int,int);
void Incrment();
void Write() const;
bool Equal(Time) const;
bool LessThan(Time) const;
Time(int,int,int);
Time();
};//time.cpp#include "Time.h"
#include
using namespace std;
void Time::Set(int hours,int minutes,int seconds)
{
hrs=hours;
mins=minutes;
secs=seconds;
}
void Time::Incrment()
{
secs++;
if(secs>59)
{
secs=0;
mins++;
if(mins>59)
{
mins=0;
hrs++;
if(hrs>23)
hrs=0;
}
}
}
void Time::Write()const
{
if(hrs<10)
cout<<'0';
cout<
cout<<'0';
cout<
cout<<'0';
cout<
bool Time::Equal(Time otherTime)const
{
return (hrs==otherTime.hrs&&mins==otherTime.mins&&secs==otherTime.secs);
}
bool Time::LessThan(Time otherTime)const
{
return (hrs
}
Time::Time(int hours,int minutes,int seconds)
{
hrs=hours;
mins=minutes;
secs=seconds;
}
Time::Time()
{
hrs=0;
mins=0;
secs=0;
}
Time类
TIME
time
that time
MY TIME
MY TIME
TIME 时间篇
TIME | Breaking Away
英汉名言(time)
Set time in perl
Network Time Protocol
Wrong time, wrong place
TIME GOES BY
时间管理 Time Management
Bicycle beam time
The Old Time Gospel
The Time Thieves2
the history of time
LONG TIME NO SEE
TIME GOES BY
时间管理 Time Managementk
Subway Time | 地铁时间
Killing Time at Home
唯有时光(Only Time)