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(); } }