SET THE DEFAULT LANGUAGE TO VISUAL BASIC AND THE STEREOTYPE DISPLAY TO LABEL -
Select the Tools:Options menu command. -
Select the Notation tab. -
Click the arrow in the Default Language field to make the drop-down menu visible. -
Select Visual Basic. -
Select the Diagram tab. -
Select the Label radio button in the Stereotype Display field. -
Click the OK button to close the Options window. SET VISUAL BASIC CODE GENERATION OPTIONS -
Select the Tools:Visual Basic:Properties menu command. -
Deselect the Generate debug code and the Generate error-handling code checkboxes. -
Click the OK button to close the Visual Basic Properties window. CREATE THE PAYCLERK CLASS -
Click the + next to the Logical View package in the Browser to expand the view. -
Double-click on the diagram called Main to open the diagram. -
Select the Class icon on the toolbar. -
Click on the Main class diagram to create the class. -
While the class is still selected, enter its name . . . Payclerk. GIVE THE PAYCLERK DOCUMENTATION AND AN OPERATION -
Double-click on the class on either the Main class diagram or in the Browser to open the Class Specification. -
Enter the documentation for the Payclerk in the Documentation field . . . a Payclerk calculates weekly pay. -
Select the Operations tab. -
Right-click to make the shortcut menu visible. -
Select the Insert menu choice. This will insert an operation called opname. -
While the operation is still selected, enter its name . . . calcPay. -
Click the OK button to close the Class Specification. SET THE ARGUMENTS AND RETURN TYPE FOR THE CALCPAY OPERATION -
Click the + next to the Logical View package in the Browser to expand the package. -
Click the + next to the Payclerk class in the Browser to expand the class. -
Double-click on the calcPay operation to make the Operation Specification visible. -
Click the arrow in the Return class field to make the drop-down menu visible. -
Select Currency. -
Select the Detail tab. -
Right-click in the Arguments field to make the shortcut menu visible. -
Select the Insert menu choice. This will insert an argument called argname. -
While the new argument is still selected, enter its name . . . rate. -
Click the Type field to make the drop-down menu visible. -
Select Integer. -
Click the OK button to close the Operation Specification. CREATE THE IPAYROLL INTERFACE CLASS -
Right-click on the Logical View package in the Browser to make the shortcut menu visible. -
Select the New: Interface menu choice. This will insert a new class with a Stereotype of Interface in the Browser. -
While the new interface class is still selected, enter its name . . . IPayroll. ADD THE INTERFACE CLASS TO THE MAIN CLASS DIAGRAM -
Open the Main class diagram by double-clicking on the diagram called Main in the Logical View package of the Browser. -
Click to select the IPayroll class in the Browser. -
Drag the class onto the Main class diagram. ADD AN OPERATION TO THE IPAYROLL CLASS -
Right-click on the IPayroll class on the Main class diagram to make the shortcut menu visible. -
Select the New:Operation menu choice. This will add a new operation called opname to the class. -
While the new operation is still selected, enter its name and return type . . . calcPay(rate:Integer):Currency (make sure you use this format). CREATE THE PAYROLL CLASS -
Right-click on the Logical View package in the Browser to make the shortcut menu visible. -
Select the New: Class menu choice. This will insert a new class in the Browser. -
While the new class is still selected, enter its name . . . Payroll. ADD THE PAYROLL CLASS TO THE MAIN CLASS DIAGRAM -
Open the Main class diagram by double-clicking on the diagram called Main in the Logical View package of the Browser. -
Click to select the Payroll class in the Browser. -
Drag the class onto the Main class diagram. CREATE A REALIZE RELATIONSHIP BETWEEN THE IPAYROLL CLASS AND THE PAYROLL CLASS -
Click to select the Realize icon on the toolbar. -
Click on the Payroll class on the Main class diagram and drag the association to the IPayroll class. CREATE A RELATIONSHIP BETWEEN THE PAYROLL CLASS AND THE PAYCLERK CLASS -
Click to select the Unidirectional Association icon on the toolbar. -
Click on the Payroll class on the Main class diagram and drag the association to the Payclerk class. CREATE A ROLL NAME -
Right-click on the association near the Payclerk class to make the shortcut menu visible. -
Select the Role name menu choice. This will add a role name called thePayClerk to the diagram. -
While the role name is still selected, enter its name . . . myClerk. MAKE THE ASSOCIATION PRIVATE -
Right-click on the association near the Payclerk class to make the shortcut menu visible. -
Select the Private menu choice. SET THE MULTIPLICITY -
Right-click on the association near the Payclerk class to make the shortcut menu visible. -
Select the Multiplicity:1 menu choice. USE THE MODEL ASSISTANT TO SET CODE GENERATION PROPERTIES FOR THE IPAYROLL INTERFACE -
Right-click on the IPayroll class on the class diagram or in the Browser to make the shortcut menu visible. -
Select the Model Assistant menu choice. -
Select IPayroll in the Model Assistant tree view. -
Click the arrow in the Instancing field to make the drop-down menu visible. -
Select MultiUse. -
Click the OK button to close the Model Assistant. USE THE MODEL ASSISTANT TO SET CODE GENERATION PROPERTIES FOR THE PAYROLL CLASS -
Right-click on the Payroll class on the class diagram or in the Browser to make the shortcut menu visible. -
Select the Model Assistant menu choice. -
Select Payroll in the Model Assistant tree view. -
Click the arrow in the Instancing field to make the drop-down menu visible. -
Select MultiUse. -
Click the + next to the Implements Classes package in the tree view to expand the view. -
Click the + next to IPayroll in the tree view to expand the view. -
Select the IPayroll_calcPay operation. -
Select the Public radio button in the Access field. -
Click the + next to the Properties package in the tree view to expand the view. -
Click the + next to myClerk in the tree view to expand the view. -
Select myClerk. -
Click the New checkbox. -
Click the OK button to close the Model Assistant. CREATE THE PAYROLLCALCULATOR COMPONENT -
Right-click on the Component View package in the Browser to make the shortcut menu visible. -
Select the New: Component menu choice. This will add a component called NewComponent to the Browser. -
While the new component is still selected, enter its name . . . PayrollCalculator. ASSIGN A STEREOTYPE TO THE PAYROLL -
Right-click on the PayrollCalculator component in the Browser to make the shortcut menu visible. -
Select the Open Specification menu choice. -
Click the arrow in the Stereotype field to make the drop-down menu visible. -
Select ActiveX DLL. -
Click the OK button to close the Component Specification. ADD THE COMPONENT TO THE MAIN COMPONENT DIAGRAM -
Double-click on the diagram called Main in the Component View package of the Browser to open the diagram. -
Click to select the PayrollCalculator component in the Browser and drag it onto the diagram. ASSIGN THE CLASSES TO THE PAYROLLCALCULATOR COMPONENT -
Double-click on the Payroll component on the diagram or in the Browser to make the Component Specification visible. -
Select the Realizes tab. -
Click to select the IPayroll class. -
Press the Shift button. -
Click to select the Payroll class. -
Click to select the Payclerk class. -
Right-click to make the pop-up menu visible. -
Select the Assign menu choice. -
Click the OK button to close the Component specification. GENERATE THE VISUAL BASIC CODE -
Click to select the PayrollCalculator component on the Component Diagram. -
Select the Tools:Visual Basic:Update code menu choice to make the Code Update tool visible. -
Select the Finish button on the Code Update tool. -
You will be prompted to save the model. Enter PayrollCalculator in the Filename field and click the Save button. -
When the code generation is complete, the Summary window is displayed. Click the Close button to close the Code Update tool. ADD THE METHOD CODE FOR THE PAYCLERK CLASS -
In Visual Basic, go to the calcPay method of the Payclerk class. -
Add the following code: calcPay = rate * 40 -
In Visual Basic, go to the IPayroll_calcPay method of the Payroll class. -
Add the following code: IPayroll_calcPay = myClerk.calcPay(rate) -
Select the Project:PayrollCalculator Properties menu choice. -
Click the arrow in the Startup Object field to make the drop-down menu visible. -
Select (None). -
Click the OK button to close the Project Properties window. -
Select the File:Make PayrollCalculator.dll . . . menu choice. -
Click the OK button in the Make Project window to save the new dll. -
Select the File:Exit menu choice to exit Visual Basic (you do not have to save the files). |