< Previous | Next >

Lesson 1: Visualize the Shapes project

In this exercise, you visualize the C++ Shapes project to view the class hierarchy.
The C++ Shapes project contains a set of classes that represents 2-dimensional and 3-dimensional shapes. The shape class is the base class from which every other class inherits. The shape2d class and the shape3d class inherit from the base shape class to represent 2-dimensional and 3-dimensional shapes. Accordingly, each shape inherits from either the 2-dimensional shape class or the 3-dimensional shape class.

Visualize the base shape classes

You can use the C++ visual development tools to view the hierarchy of your application before you extend it. You can better understand the structure of the application by viewing the relationships between the classes. You can also use the C++ visual development tools to quickly extend your applications by using the class diagram modeling interface.

Before you begin, you must import the Shapes project. Click Import the C++ Shapes project to import the Java project into your workspace.

Import the C++ Shapes project

To compile the project, you must have a compatible C++ compiler installed.

To visualize the base shape classes:

  1. In the C++ perspective, in the C++ Projects Explorer view, expand Shapes.
  2. Expand the shape.h class, right-click the Shape class element; then click Visualize > Add to New Diagram File > Class Diagram.
  3. In the C/C++ Project Explorer view, expand shape2d.h, click the shape2d class element, and drag it into the diagram editor.

You have now visualized the base classes of the C++ Shapes project. Your diagram should look similar to the following figure:

The base shapes classes are visualized by using the UML visual development tools

Visualize the circle and sphere classes

You can visualize the shape and circle classes to better view and understand the project hierarchy.

To visualize the circle and sphere classes:

  1. In the C/C++ Project Explorer view, expand the circle.h class, click the circle class element, and drag it into the diagram editor.
  2. Expand the sphere.h class, click the sphere class element, and drag it into the diagram editor.

You have now visualized the circle and shape classes. Your diagram should look similar to the following figure:

The base shapes classes are visualized in the diagram editor.

The diagram represents the hierarchy of the Shapes project. The diagram shows the visualized classes, their operations, and the inheritance and usage relationships that exist between classes. This diagram illustrates the 2-dimensional and 3-dimensional class hierarchies and their relationship to the base shape class.

In the next exercise, you use this diagram to visually extend the Shapes project.

< Previous | Next >

Feedback