Hi aaj,
I would suggest defining interfaces for IWheel, IPedal, and IHandlebar, then
having Class A, B or C implementing those interfaces where appropriate. If
the implementation is common (ie IWheel.Rotate would be implemented the same
in Class A, B or C) then I would have an internal Friend class which
provides the common code for this that you can just call into, therefore
preventing duplication of code.
I believe what you really want to accomplish would be possible if .NET
supported multiple object inheritance, which it doesn't (however I believe
C++ does?). That way, Class A could inherit from Wheel and Pedal, Class B
could inherit from Pedal and Handlebar etc. I've always this would be a
nice feature in .NET, but I can understand why MS chose not to implement it
as part of the CLR.
Cheers,
Alex Clark
"aaj" <(E-Mail Removed)> wrote in message
news:1110976489.97a40d25aacc114017a25adca7919426@teranews...
> Similar but not exactly
>
> I want to have a wheel that is a base class, a pedal thats a base class
> and a handlebar thats a base class
>
> I want a new object called a bike that is an aggregate of a wheel, a
> handlebar and a pedal
>
> i.e. my bike 'has a' handlebar and 'has a' wheel (its a unicycle) and 'has
> a' pedal (only one at this stage)
>
>
> I hope I'm asking the right question here, but I'm pretty sure I'm not
> looking for inheritance
>
> hope it makes sense
>
> Andy
>
>
>
> "Cor Ligthert" <(E-Mail Removed)> wrote in message
> news:%23iV$(E-Mail Removed)...
>> aaj,
>>
>> You mean that your car has a property wheel, a property pedal and a
>> propety handlebar.
>>
>> The value of those are a wheelobject a pedalobject and a handlebar
>> object.
>> Because it is a class, it are not collections?
>>
>> I don't think that a car has methods from a wheel, a pedal or a handlebar
>> that are carparts.
>>
>> Thererfore you can have a class carparts.
>>
>> And a class wheel, pedal and handlebar, which inherits than from
>> carparts.
>>
>> Is that what you mean?
>>
>> Cor
>>
>
>
|