Chapter 5: Creating and Building Projects

139

class named Staff, a normal class named Teacher, an inheritance relationship where Teacher derives from Staff, and an association from Program to Staff.

To create a new object, drag-and-drop the object from the Toolbox to the Class Designer surface; you’ll see an input window similar to Figure 5-15.

The New Abstract Class window in Figure 5-15 is typical of most of the Class Designer objects you can add to a diagram where you fill in the initial data for naming the class and specifying the file the code will be added to. Not all Toolbox options work this way, though; associations and inheritance work by selecting the item in the Toolbox, selecting the object where the line begins in the Class Designer, and dragging the line to the object in the Class Designer being referenced.

The other two places you can modify data are in the Class Details and Properties windows. You can see how I added the GradePapers method in Class Details. You can add members to an object yourself by clicking the object in Class Designer, and then adding the member in Class Details. The GradePapers method also has a Summary comment for documentation and a parameter named papers with a type of List<string>.

The Properties window is context-sensitive, showing you what options are available for whatever you have selected in the Class Designer. In Figure 5-14, the Teacher class is selected in Class Designer and the Summary property in the Properties window was filled in with a comment. Listing 5-3 shows the code from the Teacher.cs (Teacher.vb in VB) file that was generated after all of these actions in the graphical designer.

Figure 5-15 Adding a new object to the Class Designer

Page 162
Image 162
Microsoft 9GD00001 manual 139, Adding a new object to the Class Designer