T
Tony Johansson
Hello!
Assune I have differentf FreightCars for example Tanker and Boxcar and
maybe some other shape of Freightcar.
FreightCars is a kind of vehicle pulled by a train.
If I would calculate for example the volume for these two I would first
create an abstract class called
Freightcar and then have Tanker and Boxcar as derived classes.
Now to my question: Assume the the most common Freight car is the Boxcar.
Is it better to have the method CalcVolume as an abstact method in the
baseclass and implement the CalcVolume in correct way in each derived class
?
Or put the CalcVolume for the Boxcar in the Base class and CalcVolume for
the Tanker in the tanker class ?
Next question is it any point not to let Freightcar be an abstract class?
I think it would be a clearer solution to let CalcVolume be an abstact
method in the Base class.
I would put general field like length,width,height,weight and freight car
number that every freightcar have in the base class.
The radius for the Tanker would be put in the derived Tanker class.
Does it sounds correct what I's saying here or do you have some comment ?
//Tony
Assune I have differentf FreightCars for example Tanker and Boxcar and
maybe some other shape of Freightcar.
FreightCars is a kind of vehicle pulled by a train.
If I would calculate for example the volume for these two I would first
create an abstract class called
Freightcar and then have Tanker and Boxcar as derived classes.
Now to my question: Assume the the most common Freight car is the Boxcar.
Is it better to have the method CalcVolume as an abstact method in the
baseclass and implement the CalcVolume in correct way in each derived class
?
Or put the CalcVolume for the Boxcar in the Base class and CalcVolume for
the Tanker in the tanker class ?
Next question is it any point not to let Freightcar be an abstract class?
I think it would be a clearer solution to let CalcVolume be an abstact
method in the Base class.
I would put general field like length,width,height,weight and freight car
number that every freightcar have in the base class.
The radius for the Tanker would be put in the derived Tanker class.
Does it sounds correct what I's saying here or do you have some comment ?
//Tony