第一次写blog,很多都不懂,第一个java程序,虽然啥都不会,但是兴趣还是有的,哈哈。

public class Disply {
	private int limit = 0;
	private int value = 0;
	
	public Disply (int limit) {
		this.limit = limit;
	}
	
	public void Increase() {
		value++;
		if (value == limit) {
			value = 0;
		}
	}
	public int getValue() {
		return value;
	}
}

 

 

public class Cloke {
	private Disply hour =new Disply(24);
	private Disply minute=new Disply(60);

	public void start() {
		while(true) {
		minute.Increase();
		if(minute.getValue()==0 )
		{
		hour.Increase();
		}
		System.out.printf("%02d:%02d\n", hour.getValue(),minute.getValue());
		}
	}
	public static void main(String[] args) {
		Cloke clock=new Cloke();
		clock.start();
		}
}