If you want a method to intake an object of a superclass type, but you want it to do things differently depending on what subclass it is, is it possible to take input as the superclass, and then refer to fields of the subclass within that method?
So if i wanted to take an object of type shape, but depending on what shape it might be I want to do things differently... like a circle has a radius,but a rectangle doesnt.
ie.. (This is a very dodgy pseudo code type explanation of what I want to do..)
public void method(Superclass object) {
if (object type Subclass)
do this and refer to fields in subclass
else if (object type Subclass 2)
do this and refer to fields in subclass...
etc...
}
I really want to stick with the input being of the superclass type. Is this possible?