Say I have a base Shape class. And then some subclasses like circle and square.
Next, create a method in another class called GetShape:
public Shape GetShape()
{
return new Circle();
}
Ok, so the idea is that I can go into shapeType and then get a strongly typed subclass of Shape. The above example is a massive simplification of the real code, but I think it makes sense.
So, how, when calling this method, it will look like
var shapeCreator = new ShapeCreator();
Circle myCircle = shapeCreator.GetShape();
The only problem is that it does not even start, since it requires a throw.
This really works:
Circle myCircle = (Circle) shapeCreator.GetShape();
I'm not alone with this actor, how can I avoid it and still follow the way to return the baseclass method so that I can return any compatible subclass.