网易云课堂——Java语言程序设计进阶——第二周编程题

【网易云课堂——Java语言程序设计进阶——第二周编程题】Clock类的代码:
public class Clock {

Display hour=new Display(24); Display minute=new Display(60); Display second=new Display(60); public Clock(int a, int b, int c){ hour.setvalue(a); minute.setvalue(b); second.setvalue(c); } public void tick(){second.increase(); if(second.getvalue()==0){ minute.increase(); if(minute.getvalue()==0){ hour.increase(); } } }public String toString(){ return String.format("%02d:%02d:%02d\n",hour.getvalue(),minute.getvalue(),second.getvalue()); }

Display类部分的代码:
public class Display {
private int value=https://www.it610.com/article/0; private int limit=0; public Display(int limit){ this.limit=limit; } public void setvalue(int value){ this.value=value; }public void increase(){ value++; if(value==limit){ value=0; } }public int getvalue(){ return value; }String.format("%02d:%02d:%02d\n",hour.getvalue(),minute.getvalue(),second.getvalue()); }

    推荐阅读