Written by Bruth_Lee in Southwest University of Science And Technology.
Print out a day'time in Java.
For example:
package primer_java;
public class Display {
private int value = 0;
private int limit = 0;
public Display(int limit) {
this.limit = limit;
}
public void increase() {
value++;
if(value == limit) {
value = 0;
}
}
public int getValue() {
return value;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Display hour = new Display(24);
Display minute = new Display(60);
int c=0;
while(c<1440) {
minute.increase();
if(minute.getValue() == 0) {
hour.increase();
}
if(minute.getValue()<10) {
System.out.println(hour.getValue()+" : "+0+minute.getValue());
}else {
System.out.println(hour.getValue()+" : "+minute.getValue());
}
c++;
}
}
}