#include <bits/stdc++.h>
#define Max 1010000
using namespace std;
class Time{
private:
int hour, minute, second;
void setHour(int x)
{
if(x > 1 && x <= 12)
{
hour = x;
}
else{
hour = 12;
}
}
void setMinute(int y)
{
if(y >= 0 && y < 60)
{
minute = y;
}
else{
minute = 0;
}
}
void setSecond(int z)
{
if(z >= 0 && z < 60)
{
second = z;
}
else{
second = 0;
}
}
public:
void setTime(int x, int y, int z)
{
setHour(x);
setMinute(y);
setSecond(z);
}
void showTime()
{
printf("%d:%d:%d\n",hour, minute, second);
}
};
int main()
{
Time time;
int x, y, z;
cin >> x >> y >> z;
time.setTime(x, y, z);
time.showTime();
return 0;
}
1144-面向对象程序设计上机练习五(类和对象)
最新推荐文章于 2020-05-06 15:22:23 发布