功能:顺计时、倒计时
实现:
1、顺计时
public class MyTime {
private int hour;
private int minute;
private int second;
public MyTime(int hour, int minute, int second) {
check(hour,minute,second);
this.hour = hour;
this.minute = minute;
this.second = second;
}
public MyTime(MyTime time){
this(time.hour,time.minute,time.second);
}
private void check(int hour,int minute,int second) {
if (hour<0||hour>=24){
throw new RuntimeException("hour参数错误");
}
if (minute<0||minute>=60){
throw new RuntimeException("minute参数错误")