Use Visio to draw a UML class diagram

Source: Internet
Author: User

There are many tools for painting class diagrams. I have learned how to use staruml to draw class diagrams. However, this tool is used in Java. For vs programming C ++, I personally feel that Using Visio is better. The following uses a block class in the previous Tetris game as an example to describe it.

1 class block
2 {
3 public:
4 block (void );
5 void Init (); // Initialization
6 void newblock (); // create a square
7 point * getblockdata (); // obtain the coordinate of the square
8 int * getkind (); // obtain the block type
9 int * getstatu (); // get the square status
10 int * getnextkind (); // obtain the next block type
11 ~ Block (void );
12 private:
13 point blockdata [4]; // block data
14 int kind; // block type
15 int nextkind; // The type of the next Square
16 int statu; // block status
17 };

First, create a class chart. Next, let's make some preparations, because the point type in psdk is used here, and the data type cannot be found in the Visio data type, so we need to append the Data Type first. To facilitate management, we will first create a psdk data type package.

Create a data package: menu-> UML-> package. Open the [UML package] dialog box. Click the [new] button, enter the [psdk data type] in the [Package] column, and click OK.

Append point data type:

In this case, we can see that the model Resource Manager (if there is no window on the left, you can select the psdk data type you just created from the menu> UML> View> model resource manager, right-click-> New-> data type to open the UML data type attribute dialog box. Select a [data type] project, enter [point] in the project name, and select [OK] to end.

Note: In psdk, point is a struct, but we do not care about the details of point, so we treat point as a simple data type.

Class: it is easy to add a class. You can drag an object from the [UML static structure] class in the shape window.

 

Set the class details: most of the work of setting the class details is implemented in the attribute dialog box at the same time. for C ++ programmers, the content to be set includes class names, data members, and member functions ..

Double-click the class or right-click and choose Properties to open the UML class Properties dialog box. Select a [Class] project in [category], and write the class name in the name column on the right. You can also set some attributes of the class.

Add a data member to add a member function to the table on the right .. The variable name is written in the [feature] column. The [type] is used to select the data type. Here we select [point]. In the [visibility] column, this member is public (private ). [Multiple] indicates the number of data members in a class. [1] indicates that there is only one data member in this class. [0 .. 1] indicates that there is no or one. You can enter the initial values of data members in [initial values. Add other data members.

Add member function: in the [category] window, select the [operation] project. Append a member function to the right table. In [operation], write the function name. In [visibility], select whether the function is shared, protected, or private. [Polymorphism] indicates whether to use a virtual function. [Range] indicates whether a function belongs to an instance, a class, a static function, or a member function of a class. A common member function is also called a member function of an instance. If [classifier] is selected, it indicates that this function is a static function.

The above operation only sets some basic information about the function. For more details, you can select the function and click the [attribute] button to set it in the [UML operation attribute] window that appears. First, set the basic information of the function. The content repeated with the preceding window is not described. Only [prefix] and [suffix] are described. If we want to return a pointer type or an application type, we only need to enter [*] or [&] in the [suffix.

After completion

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.