1个回答
展开全部
package test;
public class MyTime {
private int hour;
private int minute;
private int second;
public MyTime() {
this.hour = 0;
this.minute = 0;
this.second = 0;
}
public MyTime(int h, int m, int s) {
this.hour = h;
this.minute = m;
this.second = s;
}
public void addOneSecond() {
this.second = this.second + 1;
}
public int different(MyTime mt) {
int diff = 0;
diff = (this.hour - mt.getHour()) * 360
+ (this.minute - mt.getMinute()) * 60 + this.second
- mt.getSecond();
return diff;
}
public int getHour() {
return hour;
}
public void setHour(int hour) {
this.hour = hour;
}
public int getMinute() {
return minute;
}
public void setMinute(int minute) {
this.minute = minute;
}
public int getSecond() {
return second;
}
public void setSecond(int second) {
this.second = second;
}
@Override
public String toString() {
return "MyTime [" + hour + "-" + minute + "-" + second + "]";
}
}
public class MyTime {
private int hour;
private int minute;
private int second;
public MyTime() {
this.hour = 0;
this.minute = 0;
this.second = 0;
}
public MyTime(int h, int m, int s) {
this.hour = h;
this.minute = m;
this.second = s;
}
public void addOneSecond() {
this.second = this.second + 1;
}
public int different(MyTime mt) {
int diff = 0;
diff = (this.hour - mt.getHour()) * 360
+ (this.minute - mt.getMinute()) * 60 + this.second
- mt.getSecond();
return diff;
}
public int getHour() {
return hour;
}
public void setHour(int hour) {
this.hour = hour;
}
public int getMinute() {
return minute;
}
public void setMinute(int minute) {
this.minute = minute;
}
public int getSecond() {
return second;
}
public void setSecond(int second) {
this.second = second;
}
@Override
public String toString() {
return "MyTime [" + hour + "-" + minute + "-" + second + "]";
}
}
追问
请问应该如何测试呢?就是TestMyTime.java 应该怎么写呢
追答
你可以写一个class test, 里面有mian, 来测试,
或者你可以用junit来测试
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询