Thanks for taking the time too look at my question. It's pretty general but I can't seem to find very much information on it. I've looked at similar questions but none of the examples seem to be this convoluted.
In C++ I am looking for the proper way that sub-classes should interact given that each pair has a different set of operations.
Lets say I have the following classes with sub-classes.
Vehicle Tires
| |
Motorcycle / | \
/ | \ Snow Seasonal Summer
Honda Suzuki Yamaha
Let's say I have a function for each type (Honda, Suzuki, Yamaha) called Performance(Tires tires)
that does certain operations based on the type of tires. I was wondering what would be the "best practices" way to implement this in a general way. The issue that I am running into is that each pair has different operations that need to be done, e.g. Honda.Performance(snowTires)
is different from Honda.Performance(seasonalTires)
and it is also different from Suzuki.Performance(snowTires)
. My issue is that implementing something like the following seems like a poor solution because it would also have to be implemented for the other subclasses of Motorcycle.
void Honda::Performance(Tires tires)
{
if(tires are Snow)
{
//snow ops
}
elseif(tires are seasonal)
{
//seasonal ops
}
else
{
//summer ops
}
}
Any constructive suggestions or advice are appreciated.
Thanks!