发布网友 发布时间:2023-12-01 19:37
共2个回答
热心网友 时间:2023-12-02 11:32
public class MyDate {public class MyTime {
private int hour;
private int minute;
private int second;
public MyTime(int hour,int minute,int second){
this.hour = hour;
this.minute = minute;
this.second = second;
}
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 hour + "时:" + minute + "分:" + second + "秒";
}
}
public class FullTime{
private MyDate date;
private MyTime time;
public FullTime(MyDate date,MyTime time){
this.date = date;
this.time = time;
}
public MyDate getDate() {
return date;
}
public void setDate(MyDate date) {
this.date = date;
}
public MyTime getTime() {
return time;
}
public void setTime(MyTime time) {
this.time = time;
}
@Override
public String toString() {
return date.toString() + time.toString();
}
}
追问怎么在另一个类里面显示年月日时间
追答直接调用FullTime中的toString方法就可以了啊
热心网友 时间:2023-12-02 11:32
...这是求全码的节奏?