1 //write Java applications. First, define a clock class--clock, which consists of three int types2 //member variables represent hours, minutes, seconds, and a construction method for three member variables (hours, minutes, seconds)3 //for initialization, there is also a member method show () to display the time of the clock object. Second, redefine4 //a main class,--testclass, creates objects of multiple clock classes in the main method of the Master class, using this5 //Some objects call the method Show () to display the time of the clock. 6 inth;7 intm;8 ints;9Clock (intH1,intM1,intS1)Ten { Oneh1=h; Am1=m; -s1=s; - } the voidShowintHintMints) - { -System.out.println ("Present time:" +h+ "when" +m+ "minute" +s+ "seconds"); - } + - Public Static voidMain (string[] args) { +Clock clock1=NewClock (20,48,54); AClock clock2=NewClock (21,50,34); atClock clock3=NewClock (22,59,35); -Clock1.show (20,48,54); -Clock2.show (21,50,34); -Clock3.show (22,59,35); - -}
Object-oriented-clock