赞
踩
- public class Display {
- private int value=0;
- private int limate=0;
- public void increase() {
- value++;
- if(value==limate) {
- value=0;
- }
- }
- public int getvalue() {
- return value;
- }
- Display(int limate){
- this.limate=limate;
- }
-
- }
- public class Clock {
- private Display hour=new Display(24);
- private Display minute=new Display(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) {
- // TODO Auto-generated method stub
- Clock shizhong=new Clock();
- shizhong.start();
- }
-
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。