java 类和对象的小练习,时钟

package lianxiti;

public class Clock {

    int shi;
    int fen;
    int miao;
    
    Clock(int shi,int fen,int miao)
    {
        this.shi=shi;
        this.fen=fen;
        this.miao=miao;
    }
    
    void show()
    {
        if(shi<0||shi>24||fen<0||fen>59||miao<0||miao>59)
        {
            System.out.println("您输入有误");
            return;
        }
        else
        {
        System.out.println("这是"+shi+":"+fen+":"+miao);
        }
    }
}
package lianxiti;

public class TextClass {

    public static void main(String[] args) {

        Clock c1=new Clock(6,6,30);
        c1.show();
        

    }

}

posted @ 2016-05-19 16:30  ╄承诺、带给的伤痛—  阅读(161)  评论(0编辑  收藏  举报