Write Java applications. First, define a clock class--clock, which consists of three int types
Member variables represent hours, minutes, seconds, and a construction method for three member variables (hours, minutes, seconds)
For initialization, there is also a member method show () to display the time of the clock object. Second, redefine
A main class that creates objects of multiple clock classes in the main method of the primary class, using this
Some objects call the method show () to display the time of the clock.
int Shi;int Fen;int Miao; String name;public Clock (int newshi,int newfen,int newmiao,string newName) {Shi=newshi; Fen=newfen; Miao=newmiao; Name=newname;} void Show () {System.out.println ("clock" +name+ "Time Is" +shi+ ":" +fen+ ":" +miao);} public static void Main (string[] args) {clock clock1=new clock (5,30,3, "Clock1"); Clock1.show (); Clock clock2=new clock (10,25,16, "Clock2"); Clock2.show (); Clock clock3=new clock (6,45,10, "Clock3"); Clock3.show ();}
Run results
The clock display of Java object-oriented exercises