Hi,
Below you can see a simple hierarchy of Bike's family.
So, I have a Collection<Bike> and I would like to get all bikes of the certain type. What I've done is :
so I compare classes ( I dont want to use instanceof because I'm interested in a concrete class ( not superclass ).
Another way to do it is to create a BikeType class which stores and defines all used type of bikes, and then a super class Bike will have an additional field
BikeType bikeType;
and then I could compare bikes in collection using that property .
I dont know if the 2nd option is better, because when you add new class you will have to change bikeType.
What's your opinion ?