7、根據(jù)代碼構(gòu)建類圖 Vehicle c=new Car("red",“Audi",123); Vehicle t=new Tr
根據(jù)代碼構(gòu)建類圖
Vehicle c=new Car("red",“Audi",123);
Vehicle t=new Truck(“white",“Benz",300);
Driver driver=new Driver();
driver.drive(c);
driver.drive(t);
+-----------------------+
| Vehicle |
+-----------------------+
| -color: String |
| -brand: String |
| -horsePower: int |
+-----------------------+
| +Vehicle(color: String, brand: String, horsePower: int) |
| +getColor(): String |
| +getBrand(): String |
| +getHorsePower(): int |
| +setColor(color: String): void |
| +setBrand(brand: String): void |
| +setHorsePower(horsePower: int): void |
+-----------------------+
/ \
/ \
+----------+ +----------+
| Car | | Truck |
+----------+ +----------+
| +Car(color: String, brand: String, horsePower: int) |
| +getMaxSpeed(): int |
| +setMaxSpeed(maxSpeed: int): void |
+----------+ |
|
|
|
+------------------+ |
| Driver | |
+------------------+ |
| +drive(vehicle: Vehicle): void |
+------------------+
標(biāo)簽: