I have a class named component that takes a shape Object as a parameter. The main class which creates an object of component doesn't know exactly which type of shape it's sending to it, all it knows is that it sends an Abstract Shape. My component however knows it will only get a triangle and therefor use its specific attributes.
My question, How can I convert the Abstract parameter to a specific subclass of it? Example:
public class TriangleHandler extends AbstractHandler{
//More
//Code
//Here
public tick(AbstractShape shape){
shape.doTrinagleStuff();
}
}
public class MainClass{
private AbstractShape currentShape;
private AbstractHandler currentHandler;
//More
//Code
//Here
public tick(){
currentHandler.tick(currentShape);
}
}