JBuilder2005 the inheritance system such as refactoring

Source: Internet
Author: User
Tags abstract inheritance

In JBuilder, it is very easy to move the domain and method in the inheritance system of the class by refactoring. This explains this refactoring function, we first look at the following class inheritance system:

Figure 15 Inheritance class diagram of Class

The animal class is cat and horse and parent class, and animal contains two domain and one method. You can move the range of animal in a class to a subclass. In addition, you can refine the superclass and interface for animal.

1. Relocation method

Open the Animal.java and position the cursor at the Howl () method, using Ctrl+shift+r->push down method to call up the Move Down Methods dialog box:

Figure 16 Move Down method

· Method: The way to move down.

· Keep as abstract in the current class: Indicates that the class is converted to an abstract class while the next method is moved.

· Selected Subclasses: Lists all subclasses of the current class, by default the method moves down to all subclasses, we cancel cat and move howl () down to horse only.

In the method Howl (), a private variable, animal, that is referenced to the class, volume, is changed to protected int volume after the Howl () is moved.

Push and move down are the opposite actions that are responsible for pushing the methods in the subclass into the parent class. Save and recompile the project, open Horse.java and place the cursor at the Howl () method: Ctrl+shift+r->pull up to pull up the dialog box:

Figure 17

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.