In this post, we will learn how to add Constructors to a class using the Raptor flowchart. To enable UML mode in Raptor follow this link: ( Enabling UML mode in Raptor flowchart)
Launch Raptor flowchart tool. To create a new Constructor we need to create the Class.
Right-click on the class in the UML tab >> Choose Edit Members.
In the New window >> Click on the new Constructor button.
Choose the access specifier for the constructor method. It is important to note that it’s illegal to set the modifiers like static, final to the constructor methods.
Click on Close button to close the window. This would create a no-argument default Constructor to the class. For example,
Adding Constructor with arguments
To add a constructor with arguments, follow the same procedure as above, and add the arguments in the syntax field. This is called the overloading of the constructor method. Creating more than one constructors for the Car class:
public Car(String model, String make)
public Car(String model, String make, String color, double price)
Now, we can assign the parameters in the Constructor to the instance fields in the class by using this operator. this is the reference to the current object.
Raptor Tutorials on this website can be found at:
RAPTOR official website: https://raptor.martincarlisle.com/