This content has been marked as final. Show 1 reply
I have a method which uses a combination of the methods defined in Transport and Car.Note that depending on what it does (especially, if it doesn't require any state from any other entity), it might be located in class Car then.
Currently I have written the method to take a 'Transport' as a parameter and then cast that to a Car - but I dont think theres any real point in doing thatIndeed. In particular, what happens if the caller of the method passes a Transport instance that is not a car instance?
I think I should just write it to take a Car as a Parameter.Probably. Or ... Think about locating the method in class car itself.
But why have you specified the parameter to be a Transport in the first place? Are there other features, unstated so far, that would make the method apply to any kind of Transport?