• TestingDocs
TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Raptor Flowchart

Generate Java code from Raptor Flowchart

Overview

In this tutorial, we will learn steps involved to Generate Java code from Raptor Flowchart. We can generate structured code as well as object-oriented code in OO(Object-oriented) mode. When we create object-oriented flowcharts with classes we can use the OO mode in Raptor.

https://www.testingdocs.com/modes-in-raptor-flowchart/

Create Class in Raptor

https://www.testingdocs.com/creating-objects-in-raptor-flowcharts/

Example

Let’s create a class called Dog and instantiate an object in the Main flowchart. We will generate code for this flowchart.

Sample Dog class. The main flowchart instantiates an object of Dog class and prints the object information  to the Master console window.

UML Class diagram

Dog Class Raptor

Main Flowchart

Raptor Main Flowchart

Generate Java Code

Choose Generate >> Java menu option to generate the code. However, we need to modify the code to change the ?? to datatypes and correct print statements as per the Java language specification.

For example, to instantiate an object. The generate statement would be:

# Creating Objects

?? dogObject = ??;

We need to change this to:

Dog dogObject = new Dog(); // This calls the default no-arg constructor.

# Print statements

printLine(“Name = ” + this.getName());

We need to change this to:

System.out.println(“Name = ” + this.getName());

The generated code in the default IDE on the system. ( IntelliJ IDEA).

Generate Java Code

Java Code

Main Flowchart

/**
 * NAME:
 * DATE:
 * FILE:
 * COMMENTS:
 */

public class Object_Oriented_Java_main
{
 public static void main(String[] args)
 {
 // declare variables
 ?? dogObject = ??;
 
 dogObject = new Dog("Tommy",2,3.5);
 printLine("Name =" + dogObject.getName());
 printLine("Age =" + dogObject.getAge());
 printLine("Weight =" + dogObject.getWeight());
 } // close main
} // close Object_Oriented_Java

Dog Class

/**
 * NAME:
 * DATE:
 * FILE: www.TestingDocs.com
 * COMMENTS: File created by Raptor UML Mode
 */

public class Dog

{
 private int age;
 private double weight;
 private String name;
 public Dog(String name, int age, double w)
 {
 this.name = name;
 this.age = age;
 this.weight = w;
 } // close Dog
 
 public int getAge()
 {
 return this.age;
 } // close getAge
 
 public double getWeight()
 {
 return this.weight;
 } // close getWeight
 
 public void toString()
 {
 printLine("Name = " + this.getName());
 printLine("Age = " + this.getAge() + " years");
 printLine("Weight = " + this.getWeight() + " kg");
 } // close toString
 
 public String getName()
 {
 return this.name;
 } // close getName
 
 public Dog()
 {
 } // close Dog
 
} // close Dog

—

Raptor Tutorials on this website can be found at:

https://www.testingdocs.com/raptor-a-flowchart-tool/

RAPTOR official website: https://raptor.martincarlisle.com/

Related Posts

Install RAPTOR Avalonia CentOS

Raptor Flowchart /

Install RAPTOR Avalonia on CentOS

RAPTOR Avalonia Edition Windows

Raptor Flowchart /

Download RAPTOR Avalonia Edition on Windows

RAPTOR Editions

Raptor Flowchart /

RAPTOR Editions

RAPTOR flowcart to write to a file output

Raptor Flowchart /

Write to a file with RAPTOR flowchart

Sum of Squares Array Elements Modular Approach

Raptor Flowchart /

Sum of Squares of Given Array Elements

‹ Generate C++ code from Raptor Flowchart› Execute a Raptor Flowchart

Recent Posts

  • How to secure your SQL Database: Tips and Tricks
  • Shaping the Future of Development: Exploring Key Trends in Software Engineering
  • Improving Java Performance with Multithreading
  • Difference between PHP and JavaScript?
  • Bing Conversation Styles
  • ChatGPT Introduction
  • Open Source AI Frameworks
  • Artificial Intelligence Tools
  • Top AI Music Applications
  • Top AI Website Design Tools

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com