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 ,testclass, creates objects of multiple clock classes in the main method of themaster Class , using this
Some objects call the method Show () to display the time of the clock.
Package Liu0918;public class Clock {int hour;int minutes;int seconds;int Show; Clock (int h,int m,int s) {hour=h;minutes=m;seconds=s;} int Getshow () {System.out.println (the current time is: "+hour+" when "+minutes+" minutes "+seconds+" seconds "); return show; int Gethour () {return hour;} int getminutes () {return minutes;} int getseconds () {return seconds;}}
Package Liu0918;public class TestClass {public static void main (string[] args) {clock c=new clock (23,51,24); System.out.println ("Current Time:" +c.gethour () + "Time" +c.getminutes () + "Min" +c.getseconds () + "seconds"); Clock c1=new clock (10,11,12); C1.getshow (); Clock c2=new clock (22,22,22); C2.getshow ();}}
Java object-oriented--------time jobs