Design a Calculator Using Event Driven Programming Paradigm of Java
Download the latest trial version of Visual Paradigm
Unified Modeling Language (UML) is a universal modeling language independent of any specific programming language. Generally speaking, no matter what programming language is used, developers should be able to read and understand diagrams without problems. But to make things easier to understand, you can choose to present your UML class model in a specific language. Specifically, the data types that use attributes and operations can be represented by language-specific names, such as "boolean" in Java and "bool" in C#.
In this tutorial, we will show you how to present class models in different programming languages.
1. Create a project in a specific language
In this section, we will show you how to create a new project using a specific programming language. By doing this, you can easily select language-specific types when building a class model. If you haven't done this in your production project, don't worry. You can switch between languages at any time. We will show you how to do this in the next section.
-
Select Project> New from the application toolbar.
-
In the New Project window, enter Tutorial as Name.
-
By default, UML is selected as the data type set, which means you can use the original UML data type when building the model. Suppose we want to draw a class diagram for a Java project. Select Java as the data type set.
-
Click Create Blank Project.
2. Create a simple UML class diagram
In this section, you will create a class diagram that contains a class and include multiple attributes in it. You will create properties using primitive Java data types.
-
First create a UML class diagram. You can create a class diagram by selecting Diagram> New from the application toolbar. Select Class Diagram in the New Diagram window, and click Next. Click OK again to create the chart.
-
Click on the "User" category.
-
Let's add an attribute name to the class. Right-click the class and select "Add"> "Attribute" from the pop-up menu.
-
name is the (Java) String attribute. You can enter name: String to create such an attribute, but let's try something different this time. Type name and click on the chart background to create an untyped attribute.
-
Right-click the attribute and select Open Specification... from the pop-up menu
-
Click the drop-down menu next to the "Type" field. You can see a list of primitive Java data types to choose from. Now, select String and click OK to confirm.
-
Now, create two other attributes age: int and active: boolean. To save time, you can type the name and data type inline without going through the specification window.
Three, use another programming language to present the class model
Now you have a class diagram where Java data types are used as attribute types. Your Java developers are very happy. Let's entertain C# developers by presenting data types in C#.
-
Select Window> Configuration> Configure Programming Language from the application toolbar.
-
The "Programming Language" window displays the currently selected language, supported data types and their corresponding display names. We will describe in more detail in a minute. Now, change the language from Java to C#.
The list of data types has been updated and is now longer than before. If you scroll, you can see some C# types such as uint and ulong, which are not available in Java. So how to read these two columns? Let's check the String type row. The first and second columns display String and string respectively. This means that by changing the language to C#, the original String type (available under Java) will be displayed as a string.
-
Click "OK" to confirm the programming language change. You can now see that the attribute name is now displayed as a C# string, and active is now a C# bool instead of a Java boolean.
Download the latest trial version of Visual Paradigm
Design a Calculator Using Event Driven Programming Paradigm of Java
Source: https://www.programmersought.com/article/43855738712/
Post a Comment for "Design a Calculator Using Event Driven Programming Paradigm of Java"