Extending Interface to an Interface

The Procedure 

Real Lab Procedure

  • First, click on the class diagram then the below diagrams will be shown.
  • 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 class Point.
  • Fig 2 shows the class diagram of 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.

  • The class is named Point and it defines a simple 2D point with x and y coordinates. It has private methods to set and get the values of x and y. 
  • Here, an interface named Shape is defined with two methods: area() and perimeter(). It also contains a static final variable pi which is set to the value 3.14. 
  • The Circle class implements the Shape interface. It has a protected instance variable radius and provides implementations for the area() and perimeter() methods using the formulae for calculating the area and perimeter of a circle. 
  • Two interfaces X and Y are defined, each with two methods. Interface X has methods a() and b(), while interface Y has methods c() and d(). 
  • An interface named Z is defined which extends the X interface and adds the method c(). 
  • A class Z is defined which implements both interfaces X and Y. It provides implementations for all the methods defined in both interfaces (a(), b(), c(), d()), printing messages indicating that the functions are being implemented. 
  • Finally, a Driver class is defined with a main method. Inside the main method, an object of class Z is created, and the methods a(), b(), c(), and d() are called on that object, resulting in the respective messages being printed to the console. 

 

Simulator Procedure 

  • There are two buttons [Class Diagram and Sequence Diagram] on the right side of the Simulation.  
  • 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 diagrams the result box will be shown.  
  • Click on the Reset button to redo the Simulation.