![]() This is very useful when you have existing code you want to diagram or if you have modified code that was generated by StarUML by adding fields and methods and you thus want to update your diagrams to reflect those changes. StarUML is also capable of creating a class diagram from existing Java code, what is referred to as "reverse engineering" the code. ![]() You will learn more about JavaDoc in subsequent labs. The comments are written in "JavaDoc" style. Make sure you add comments to the code as shown in the sample code.Remember that the IShape getArea() method is abstract and so has no code body.We just showed it here for illustrative reasons.) (Note: the code for Test_Pizza is best autogenerated by DrJava rather than created by hand in StarUML. The code would be the same as you wrote for HW02. Use DrJava to add code to the corresponding class.You can do this by selecting "Export Diagram" on the File menu and choosing an appropriate file type. It will be useful to export diagrams to other formats, such as images.SU uses a single project file for all the information, so you should have only 1 file generated currently. You just have to experiment with the tool to get to know it. You can drag your class diagrams around and bend the arrows in many different ways (to make the arrows rectilinear, select an arrow, right click it, expand format, expand Line Style, and select Rectilinear). Feel free to make other modifications to your diagram.Your diagram should now look like the diagram at the top of this web page.Dependencies have no effect on code generation.You can move the label of the dependency line around to a more aesthetic location by selecting the label on the diagram and dragging it.Typically when one class instantiates another class, we label the dependency line "instantiates" (surprise, surprise!). Enter a label for a dependency by changing the "Name" property in the Properties box or by double-clicking the dependency line.In this example, Test_Pizza "depends" on Pizza, Circle, and Rectangle because it instantiates them. Add dependencies between different classes by selecting the "Dependency" arrow from the toolbox, selecting a dependent class, and dragging the arrow to the class it is dependent upon.Or a class's method may take another class as an input parameter, retaining a reference to it only for the duration of the execution of that method. For instance, one class may instantiate another class but not hold permanent a reference to it by using a field. Dependency lines help show relations between classes that occur more dynamically.Type in the desire name of the field, "_radius". Add an "Attribute" (or field) to Circle by right-clicking the object on the diagram, expanding the "Add" menu, and pressing the green "Attribute" button.Rename the class to Circle by double clicking on the name. This should create a new class with a generic name. Now to begin actually creating the diagram, from the "Toolbox" which starts by default on the left side of the screen, select the "Class" icon, and left-click somewhere on the diagram window.Your StarUML project should now look something like this: From the "File" menu, choose "Save", and select a location to save the project. Save the project now so you do not lose any progress if some problem arises.Be sure to include the "Java Profile" in the project. Go to "Model/Profile." to set the "profile" used by the project, which determines which symbols and conventions will be in use.Either on the main menu under "Model", or by right-clicking the selected model, got to "Add Diagram/Class Diagram":.Either on the main menu under "Model", or by right-clicking the selected model, got to "Add/Design Model". ![]() ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |