JMU
Lab: Creating Class Diagrams in Visual Paradigm


Instructions: Answer as many of the following questions as you can during the lab period. If you are unable to complete the assignment during the lab period it is strongly recommended that you complete it on your own.

1. General Preparation: Before doing anything else, if you haven't already done so, you should read a little about Visual Paradigm for UML.
  1. Open the course "Help" page on "Visual Paradigm - Tips".
  2. Read the section on "Colors, Fonts, etc...".
  3. Read the section on "Finding Icons".
  4. Read the section on "Finding Tabs".
  5. Read the section on "Exporting Diagrams".

You should also read the UML Style Guide for the course (if there is one) which can be found on the course "Policies" page.

2. Specific Preparation: To get ready for this assignment, you should do the following.
  1. If you haven't already done so, you should read a little about Class Diagrams in Visual Paradigm for UML in the course "Help" page on "Visual Paradigm - Tips" (in the section on "Class Diagrams").
  2. Review the following UML class diagram (which you will be replicating).
    diagram.png
  3. Create a new class diagram.
3. Working with Enumerated Types: This part of the lab will help improve your ability to create and edit enumerated types.
  1. Add an enumeration to the diagram. Hint: Remember, icons are sometimes stacked.
  2. Set the name of the enumeration to Grade.
  3. Right-click on Grade and pull down to Add and over to Attribute.
  4. Set the name of the attribute number.
  5. Right-click on number and pull down to Open Specification.
  6. On the "General" tab, set the "Visibility" to private, the "Type" to double, and the "Scope" to instance (i.e., non-static).
  7. Select Grade (if it isn't already) and press Alt+Shift+A (which is a shortcut for Add+Attribute).
  8. Set the name and type of the attribute by entering letter:String. (Note: By default, attributes are private and non-static.
  9. Right-click on Grade and pull down to Add and over to Enumeration Literal.
  10. Set the name of the literal to A.
  11. Select Grade (if it isn't already) and press Alt+Shift+L (which is a shortcut for Add+Enumeration Literal) and set the name to B.
  12. Press Enter and add the literal C.
  13. Add the literals D and F.
  14. Right-click on Grade and pull down to Add and over to Constructor.
  15. Right-click on the constructor and pull over to Open Specification.
  16. On the "General" tab, set the visibility to private.
  17. Why shouldn't constructors in enumerations be public?


    Because an enumeration is an extensive definition of a set, and the creator of the enumeration constructs all of the instances. Nobody else has any need of the constructor.
    Expand
  18. Right-click on Grade and pull down to Add and over to Operation.
  19. Set the name of the operation to getLetter.
  20. Right-click on getLetter() and pull down to Open Specification.
  21. Make the "Return type" String (with a uppercase "S").
  22. Select Grade (if it isn't already) and press Alt+Shift+O (which is a shortcut for Add+Operation) and set the signature to getNumber():double.
4. Working with Classes: This part of the lab will help improve your ability to create and edit enumerated types.
  1. Add a class to the diagram. Hint: Remember, icons are sometimes stacked.
  2. Set the name of the class to Course.
  3. Add the necessary non-static attributes to Course (as in the Class Diagram you are replicating) using any of the techniques you used to add an attribute to the Grade enumeration .
  4. Add an attribute to Course named CREDIT_LIMT.
  5. Right-click on CREDIT_LIMIT and pull down to Open Specification.
  6. On the "General" tab, set the "Initial value" to 6, the "Visibility" to public, the "Type" to int, and the "Scope" to classifier (i.e., static).
  7. On the "Attribute Code Details" tab select final.
  8. Add a constructor to the Course class.
  9. Right-click on the constructor and pull down to Open Specification.
  10. Click on the "Parameters" tab.
  11. Click on Add... and add a parameter with a "Name" of department, a "Type" of String, and a "Direction" of in.
  12. Add the other parameters to the constructor.
  13. Click on the "Raised Exceptions" tab.
  14. Click on Add and pull down to Text. (Note: You would use Model if the exception you want to add is a class in the diagram. In this case, it's an exception that is part of the Java API and is not explicitly included in the diagram.)
  15. Set the "Text" to IllegalArgumentException and click on OK
  16. Click on OK and re-size the Course class if necessary.
  17. If the exception is not shown, right-click on Course, pull down to Presentation Options, pull over to Operations, and select Show Raised Exceptions.
  18. Add the necessry methods to the Course class using any of the techniques you used to add a method to the Grade enumeration.
5. Creating Interfaces and Using Parameterized Types: This part of the lab will help improve your ability to create and edit interfaces and to work with parameterized types.
  1. Add an interface to the diagram. Hint: Remember, icons are sometimes stacked.
  2. Set the name of the interface to Comparator.
  3. Right-click on Comparator and pull down to Open Specification.
  4. On the "Template Parameters" tab, click on Add... and add a parameter with a "Name" of T.
  5. If T is not visible in the diagram, right-click on Comparator, pull down to Presentation Options, and select Show Template Parameters.
  6. Add a compare() method with the appropriate signature.
  7. Right-click on compare() and pull down to Open Specification.
  8. On the "General" tab, select Abstract.
6. Working with Packages: This part of the lab will help improve your ability to create and edit packages types.
  1. Create a package named registrar.
  2. Re-size and re-position registrar so that Grade and Course are inside of it.
  3. If asked whether you want to "Add covered shapes as children?" select Yes.
  4. Create a package named util that contains Comparator.
  5. Create a package named java that contains util.
7. Working with Realizations/Specializations: This part of the lab will help improve your ability to create and edit realizations and specializations.
  1. Add the CreditComparator class to the registrar package.
  2. Draw a realization arrow from the Comparator interface to the CreditComparator class. Hint: Remember, icons are sometimes stacked.
  3. Bind the parameter T in the Comparator interface to Course by right-clicking on the realization arrow, pulling down to OpenSpecification, selecting the "Stereotypes" tab, clicking on Edit Stereotypes..., clicking on Add..., and setting the "Name" to bind t->Course.
  4. If the stereotype is not visible, right-click on the realization arrow, pull down to Stereotypes and select bind t->Course.
  5. Right-click on CreditComparator, pull down to Presentation Options, over to Class Members, add select Hide All Class Members.
  6. Add the IDComparator class.
8. Working with Associations: This part of the lab will help improve your ability to create and edit associations.
  1. Draw an association from CreditComparator to Course.
  2. Right-click on the association and pull down to Open Specification.
  3. Set the "Role" on the CreditComparator end (i.e., the "End From") to "compares".
  4. Add the association from IDComparator to Course.
9. Generating Code from Class Diagrams: This part of the lab will help you learn how to generate code from UML Class Diagrams.
  1. Click on Tools.
  2. Click on Code and select Generate Java Code.
  3. Click on Ignore Classes.
  4. Select the java package and click on > and OK.
  5. Set the "Source Path" as appropriate (which is where the generated code will be located).
  6. Click on OK.
10. Changing the Level of Abstraction: This part of the lab will help you learn how to generate class diagrams that are more/less abstract.
  1. At a low level of abstraction it is useful to include attributes in class diagrams, but at a higher level of abstraction it isn't. Select both the Grade enumeration and the Course class (e.g., by clicking on one and control-clicking on the other), right-click on one of them, pull down to Presentation Options, over to Attributes, and over to Hide All.
  2. To get the "big picture" of how classes interact, it is sometimes useful to exclude even the operations/methods from classes. Select both the Grade enumeration and the Course class, right-click on one of them, pull down to Presentation Options, over to Operations, and over to Hide All.

Copyright 2016