Hello,
I have an object tree that looks something like
Ball
/ \
LegalBall IllegalBall
And I have 2 methods:
class o {
AddBall(LegalBall l)
AddBall(IllegalBall i)
}
in another class I'd like to do the following:
o.AddBall(myBall);
where myBall is of type Ball. And get it to call the correct method depending on the subtype. Apparently I can't do this... the arguments are not applicable.
Does anyone know how I can achieve what I want? Or if there is a good work around
Thanks
EDIT : the application I'm trying to build is a Cricket scorecard type thing. So depending on the type of ball that is bowled various other elements should change.
my original intention was to be able to specify the ball type and runs scored from some form of UI and then create an appropriate type ball from a BallFactory and then for example when I send a no ball to the team score it will add the value onto the team score but also add the value to the no balls counter. But when i give the same ball to the Batsmens Analysis to deal with it should only score value-1 to the batsmens total..
I hope thats not too bad an explanation of my original intention.