Defining Printers Printing the Output

# The Procedure

## Real Lab Procedure

• There are two classes in the program, and it has three parts [class name, variables, function]

Fig. 1

Fig. 2

• Fig. 1 shows the Class Diagram of a public class “Point”.
• Fig. 2 shows the Class Diagram of a public class “Driver”.
• Then click on the Sequence Diagram which will show how the program that on the left side is executed.

Sequence diagram

Following steps are explaining Sequence Diagram

• Declare a public class named "Point."
• Inside the Point class, declare two private integer variables, 'x' and 'y'. These variables will store the 'x' and 'y' coordinates of the point.
• Define two private void methods, 'setX' and 'setY'. These methods are used to set the values of the 'x' and 'y' variables, respectively.
• The 'setX' method takes an integer parameter named 'xCoord', representing the desired x-coordinate value. Inside the method, the value of 'x' is assigned the value of 'xCoord' using the "this" keyword to refer to the current object's 'x' variable.
• Similarly, the 'setY' method takes an integer parameter named 'yCoord', representing the desired y-coordinate value. Inside the method, the value of 'y' is assigned the value of 'yCoord' using the "this" keyword to refer to the current object's 'y' variable.
• Define two private int methods, 'getX' and 'getY'. These methods are used to retrieve the values of the 'x' and 'y' variables, respectively.
• The 'getX' method returns the value of the 'x' variable using the "this" keyword to refer to the current object's 'x' variable.
• The 'getY' method returns the value of the 'y' variable using the "this" keyword to refer to the current object's 'y' variable.
• Define a private method named "print" that prints the coordinates of the point in the format "(x, y)" using the values of 'x' and 'y'.
• Declare of a public class named "Driver." This class serves as the entry point of the program.
• Inside the Driver class, define  a public static method named "main".
• Inside the main method, a new instance of the Point class is created using the "new" keyword and assigned to a variable named "p."
• The 'setX' method is called on the "p" object, passing the value 2 as the argument.
• Similarly, the 'setY' method is called on the "p" object, passing the value 3 as the argument.
• Finally, the print method is invoked on the "p" object, which prints the coordinates of the Point object, resulting in the output "(2, 3)."

## Simulator Procedure

• There are two buttons [Class Diagram and Sequence Diagram] on the right side of the canvas.
• First, click on the Class Diagram then the Class Diagrams will be shown.
• Then click on the Sequence Diagram, it will display two buttons – Previous and Next.
• The Next button shows the next sequence, and the Previous button shows the previous sequence.
• After all the sequence is completed the result box will be shown.
• Click on the Reset button to redo the Simulation.