Object-oriented-clock

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.