C++ 闹钟程序

#include 
#include 
#include 
using namespace std;
//时间类
class Time{
private:
    int hour;
    int minute;
    int second;
public:
    //设置时间
    void set(int h,int m,int s){
        hour = h;
        minute = m;
        second = s;
    }
    //时间走一秒,时分秒的变化情况
    void next(){
        if(second<59)
            second++;
        else if(minute<59){
            second=0;
            minute++;}
        else if(hour<23){
            minute=0;
            hour++;}
        else
            hour=0;
    }
    //得到时间
    int get(){
        return hour*10000+minute*100+second;
    }
};
//时钟类
class Clock{
private:
    Time now;
    Time ring_time;
public:
    //对表,设定初始时间
    void adjust_now(int h,int m,int s){
        now.set(h,m,s);
        cout<<"现在的时间是:"<=ring_time.get())
                cout<<'\a';
        }while(1);
    }
};

int main(){
	int h,m,s;
	cout<<"Please input now time:";
	cin>>h>>m>>s;
    Clock c;
    c.adjust_now(h,m,s);     //起始时间
    cout<<"Plseae input the ring time:";
    cin>>h>>m>>s;
    c.adjust_ring(h,m,s);    //闹铃时间

    c.run();
}


 

你可能感兴趣的:(c++)