oopclass-relationship

What would be the class relation?


Among the terms:

Motorized Vehicle, Car, Motor, Truck

I was thinking the following:

a Car is a Motorized Vehicle, a Car has a Motor, a Truck has a Motor, a Truck is a Motorized Vehicle

Q1: Am I correct in the above relations?

Q2: We now want to relate the word fan... how would that look?

my Attempt: a fan has a motor, a Motorized Vehicle has a motor, a Car is a Motorized Vehicle, a Car has a Motor, a Truck has a Motor, a Truck is a Motorized Vehicle

I need some clarification on this please....


Solution

  • This can be a good solution to the above mentioned. As a motor can be replaced in a car with a new one so you can keep aggregation in place of composition . Kindly refer the below image solution