UML class diagram

Source: Internet
Author: User

 

UML class diagram

Explain UMLClass diagram:

1. first, check the rectangle of "animal". It represents a class. This type of graph is divided into three layers. The first layer displays the name of the class. If it is an abstract class, it must be displayed in italic. The second layer is the class features, usually fields and attributes. The third layer is class operations, usually methods and actions. Pay attention to the previous symbol, ' + 'indicates Public ,' -' indicates private ,'#' protected.
2. " Flying" A rectangular box represents an interface diagram. Its main difference with a class diagram is that 《Interface The first line is the interface name, and the second line is the interface method. The interface also has another representation method, commonly known as the lollipop notation, that is, the Donald Duck class implements the "talking" interface.
Interface Ifly Interface Ilanguage
{{
Void Fly (); Void Speak ();
}}

3. Animals, birds, ducks, and duck are inherited from each other,Hollow triangle for inheritance relationship+Implementation .

4. "Dayan" implements the "Flying" interface.Implementation InterfaceHollow triangle+Dotted Line . (Note: The following figure shows a hollow triangle.)

Class BIRD: Animal Class Widegoose: ifly
{{
// Inherit animals // Implement flying Interface
}}

5. Penguins have a great relationship with climate. Penguins need to "know" about climate changes and learn about climate patterns. When one class "knows" another class, you can use Association(Association) Link.Associations are expressed by the solid arrow..
 
Class Penguin: Bird
{
Private Climate; // In penguin, the climate object of climate is referenced.
}

6. "Geese" and "Geese. Geese are group animals. Each group belongs to one group. One group can have multiple geese. So aggregation is required between them. (Aggregation) Link.Aggregation indicates a weak "ownership" relationship, which reflectsAObjects can containBObject,BObject is notAObject. Hollow diamond used for aggregation+Solid line arrow .

Class Widegooseaggregate
{
Private Widegoose [] arraywidegoose;
// In the wild goose group widegooseaggregate class, there is a wild goose array object arraywidegoose
}

7. "bird" and "Wings" are two types. The relationship between a bird and its wings is like the relationship between the whole and the part, and the life cycle of the wings is the same. Here, the relationship between the bird and its wings is synthetic. composition ) it is a strong "ownership" relationship that reflects the strict relationship between the part and the whole, the same as the overall lifecycle . solid diamond + line arrows to represent . In addition, there is a number " 1 "and number" 2 ", which is called the base number. It indicates that the class at this end can have several instances. Obviously, a bird should have two wings. If a class may have multiple instances, use " N . Association, and aggregation can also have a base.

ClassBird
{
PrivateWing wing;
PublicBird ()
{
Wing=NewWing ();
//In the bird class, wing is instantiated during initialization and is generated simultaneously between them.
}
}

8. Between "animal", "Oxygen" and "water. Animals have several major features, such as metabolism and reproduction. Animals need to have life, oxygen, water, and food. That is to say, animals depend on oxygen and water. Between them isDependency(Dependency ),Expressed by dotted arrow .

abstract class animal
{< br> Public metabolism (oxygen, water)
{< BR >}

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.