체험 시간"클래스"

2052 단어
*                                                                                
*All right reserved.                                                    
*    *                                                                                
*All right reserved.                                                    
*    :    “ ”   
*  :                                                                                
*    :2013 3 11                                                                    
*   :v1.0                                                                               
*             :    “ ”   
*    :
#include <iostream>
using namespace std;
class Time
{
    private:
    bool is_time(int ,int ,int);
    int hour;
    int minute;
    int second;
    public:
    void set_time();
    void show_time();
};
void Time::set_time()
{
     char c1,c2;
     cout<<"         (hh:jj:cc)"<<endl;
     while(1)
     {
         cin>>hour>>c1>>minute>>c2>>second;
         if(c1!=':'||c2!=':')
         cout<<"     ,     "<<endl;
         else if(is_time(hour,minute,second)==false)
         cout<<"    ,     "<<endl;
         else
         break;
     }
 }
void Time::show_time()
{
    cout<<"   "<<hour<<":"<<minute<<":"<<second<<endl;
}
bool Time::is_time(int h,int m,int s)
{
    if(h>=0&&h<24&&m>=0&&m<60&&s>=0&&s<60)
    return true;
    else
    return false;
}
int main()
{
    Time t;
    t.set_time();
    t.show_time();
    return 0;
}

실행 결과:
소감: 무슨 말을 해야 할지 모르겠어. 그만해!

좋은 웹페이지 즐겨찾기