Exercise 1:

The target of this exercise is to ilustrate the polimorphism concept.

We want to create a program, called TestP.java, to draw any object in a Display. Of course, the objects to draw must have a Draw method, but they could be trajectories, figures, images, ufos, etc. This program will be similar to the test program developed in the last laboratory session to draw trajectories, but TestP will not take care about what the classes of the managed objects are. It only requires that the objects implement the Draw method.

In this exercise, we will only use the trajectory classes developed in the last session laboratory.

Then, write a Java interface file, called DisplayDrawable, defining the following abstract method:

// Draw the trajectory in the given display 
// centered at position (x,y).
 public abstract void Draw(Display d, double x, double y);
As all the classes used by TestP must implement this interface, modify the files CircularT, LinealT, SpiralT and LissajousT to implement the DisplayDrawable interface.

Create the TestP.java program making these modifications to the TestT.java program developed in the las session laboratory:

Now, compile all the Java files and check that all the objects in the array are drawn.

Exercise 2:

The target of this exercise is to create new classes to use with the previous exercise.

Write classes to represent figures like triangles, rectangles, circles, boxes, polygons, etc, all of them implementing the DisplayDrawable interface.

Integrate them into the TestP.java program.