I have one interface
public interface GeometricObject {
public String getInfo();
}
And I have 2 classes, which implement the above interface.
public class Circle implements GeometricObject {
@Override
public String getInfo() {
return "Circle[center,radius]";
}
}
public class Triangle implements GeometricObject {
@Override
public String getInfo() {
return "Triangle[p1,p2,p3]";
}
}
And now I have this class to show all info that:
public class shapeUtils{
public String printInfo(List<GeometricObject> shapes) {
//code here
}
}
How can I call that method in all implements to that list
e.g.
Circle:
Circle[(1,2),r=3]
Circle[(5,6),r=2]
Triangle:
Triangle[(1,2),(2,3),(3,0)]
Triangle[(-1,-3),(-5,3),(0,0)]