- Select File > New > Project... from the main menu of Visual Studio.
- In the New Project window, select Class Library as template, enter PhoneBook as project name and click OK.
- In the Solution Explorer, right-click on the project PhoneBook and select Open Visual Paradigm from the popup menu.
- Click OK when the project structure dialog box appears.
- From the Diagram Navigator, right-click on Class Diagram node and select New Class Diagram from the popup menu. This creates a blank class diagram.
- Select Class from the diagram toolbar.
- Click on the diagram to create a class. Name it as Book and press Enter to confirm editing.
- Right-click on the Book class and select Add > Attribute from the popup menu.
- Input name : String and press Enter.
- Input description : String and press Enter. Press Esc to confirm editing.
- A phone book contains many contacts. Let's create a Contact class from the Book class with an association. Move the mouse pointer over the Book class. Press on the Resource Catalog icon and drag it out.
- Release the mouse button. Select Association -> Class from Resource Catalog to create the class.
- Name the class Contact.
- Right-click on the Contact class and select Add > Attribute from the popup menu.
- Input name : String and press Enter.
- Input age : int and press Enter.
- Input phoneNum : String and press Enter. Press Esc to confirm editing.
- Select Update Code from Diagram Navigator. You can see that two code files are generated.
- Add an operation printInfo in the source code of Book class.
-
Right-click on the code editor and select Update UML Model from the popup menu.
You can see that the operation printInfo() is added to the Book class at UML model side.