Zhang Xiaoxiang interprets object-oriented ideas

Source: Internet
Author: User

The ball moves on the rope and uses the object-oriented idea to compile the model.

Class rope {private point start; private point end; Public rope (point start, Point End) {This. start = start; this. end = end;} public point nextpoint (point currentpoint) {/* The next vertex of the current vertex can be calculated through the mathematical formula of the 2.1 line. This detail is not a problem to be considered during the design phase, if the current vertex is a termination vertex, null is returned. If the current vertex is not an online vertex, an exception is thrown */} class ball {private rope; private point currentpoint; public ball (rope, point startpoint) {This. rope = rope; this. currentpoint = startpoint;} public void move () {currentpoint = rope. nextpoint (currentpoint); system. out. println ("Move the ball to" + currentpoint );}}

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.