S*******C 发帖数: 822 | 1 第二个是design problem 不用写代码,给 car Honda, color, engine, Vehicle(单车
也包括在内) drive.让写他们之间的关系。
写几句话就可以了。
____________
Vehicle is an interface which declares a method drive().
Car Honda is abstract class that extends Vehicle. Car also has engine and
color as member variable.
The relationship between Vehicle and Car is inheritance.
The relationship between engine/color and Car is composition. |
p*****2 发帖数: 21240 | 2 composition 不是这个意思吧?
【在 S*******C 的大作中提到】 : 第二个是design problem 不用写代码,给 car Honda, color, engine, Vehicle(单车 : 也包括在内) drive.让写他们之间的关系。 : 写几句话就可以了。 : ____________ : Vehicle is an interface which declares a method drive(). : Car Honda is abstract class that extends Vehicle. Car also has engine and : color as member variable. : The relationship between Vehicle and Car is inheritance. : The relationship between engine/color and Car is composition.
|
S*******C 发帖数: 822 | 3 那是aggregation?
【在 p*****2 的大作中提到】 : composition 不是这个意思吧?
|
n*******s 发帖数: 17267 | 4 I would think that car:engine association is composition but
Car:color association is aggregation.
【在 p*****2 的大作中提到】 : composition 不是这个意思吧?
|
g*****g 发帖数: 34805 | 5 color is an attribute of car.
【在 n*******s 的大作中提到】 : I would think that car:engine association is composition but : Car:color association is aggregation.
|
n*******s 发帖数: 17267 | 6 That is my first understanding as well
【在 g*****g 的大作中提到】 : color is an attribute of car.
|
n*******s 发帖数: 17267 | 7 And the question is what is the relationship between
Class Car and Class Color, is it not aggregation? |
n*******s 发帖数: 17267 | 8 By the word, it certainly does not feel like it is. |
p*****2 发帖数: 21240 | 9 color is not a class
用oo不能教条呀
不是什么都是object的
【在 n*******s 的大作中提到】 : And the question is what is the relationship between : Class Car and Class Color, is it not aggregation?
|
n*******s 发帖数: 17267 | 10 Color可以是class吧,不过这些乱七八糟的说法都是Booch那帮人瞎编的,
我也是真不清楚。
【在 p*****2 的大作中提到】 : color is not a class : 用oo不能教条呀 : 不是什么都是object的
|
S*******C 发帖数: 822 | 11 The best way to define Color is enum.
【在 p*****2 的大作中提到】 : color is not a class : 用oo不能教条呀 : 不是什么都是object的
|