小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Time類

 copperpea 2009-05-24
//page434客戶主程序
#include <iostream>
#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<<endl;
 if(time1.Equal(time2))
  cout<<"Times are equal"<<endl;
 else
  cout<<"Times are NOT equal"<<endl;
 time2=time1;
 cout<<"time1: ";
 time1.Write();
 cout<<" time2: ";
 time2.Write();
 cout<<endl;
 if(time1.Equal(time2))
  cout<<"time are equal"<<endl;
 else
  cout<<"time are NOT equal"<<endl;
 time2.Incrment();
 cout<<"New time2: ";
 time2.Write();
 cout<<endl;
 if(time1.LessThan(time2))
  cout<<"time1 is less than time2"<<endl;
 else
  cout<<"time1 is NOT less than time2"<<endl;
 if(time2.LessThan(time1))
  cout<<"time2 is less than time1"<<endl;
 else
  cout<<"time2 is NOT less than time1"<<endl;
 time1.Set(23,59,55);
 cout<<"Increment time1 from 23:59:55:"<<endl;
 for(i=1;i<=10;i++)
 {
  time1.Write();
  cout<<' ';
  time1.Incrment();
 }
 cout<<endl;
}
//time.h
class 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 <iostream>
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<<hrs<<':';
 if(mins<10)
  cout<<'0';
 cout<<mins<<':';
 if(secs<10)
  cout<<'0';
 cout<<secs;
}
bool Time::Equal(Time otherTime)const
{
 return (hrs==otherTime.hrs&&mins==otherTime.mins&&secs==otherTime.secs);
}
bool Time::LessThan(Time otherTime)const
{
 return (hrs<otherTime.hrs||
  hrs==otherTime.hrs&&mins<otherTime.mins||
  hrs==otherTime.hrs&&mins==otherTime.mins&&secs<otherTime.secs
  );
}
Time::Time(int hours,int minutes,int seconds)
{
 hrs=hours;
 mins=minutes;
 secs=seconds;
}
Time::Time()
{
 hrs=0;
 mins=0;
 secs=0;
}
 

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多