AnyLogic allows the user to create their own Java classes in the model with any required functionality.
To add a Java class
- In the Projects view, right-click (macOS: Ctrl + click) the model item you are currently working with, and choose New > Java Class… from the popup menu.
The New Java Class wizard is displayed.
- On the first page of the wizard, specify the name of the new Java class in the Name field and optionally type in the superclass name in the Superclass edit box.
Click Next to go to the next page of the wizard.
- On the second page of the wizard, specify Java class fields. Fields are specified in the table, each class field is defined in the separate row. Enter the type of the field in the Type cell, name of the field in the Name cell and optionally name the access modifier in the Access cell and specify the initial value in the Initial value cell.
- Using Create constructor and Create toString() method check boxes, specify whether you want default class constructor and toString() method to be created automatically.
Click Finish to complete the process. You will see the code editor for the created class opened.
How can we improve this article?