车辆与构件类图
2019-12-19 10:15:55 1 举报
车辆与构件类图
作者其他创作
大纲/内容
Engine
+ speed : float
+ accelerate (float value) : void+ decelerate (float value) : void
Vehicle
+ serialNumber : String+ manufacturer : String+ version : String+ engine : Engine+ brake : Brake
+ drive (int status) : void+ maintain () : void
Brake
+ status : boolean
+ braking () : void+ stopBrake () : void
public class Brake {\tpublic boolean status;\t\tpublic void braking () {\t\tSystem.out.println(\"The car is braking...\");\t\tthis.status = true;\t}\tpublic void stopBrake () {\t\tSystem.out.println(\"Braking is being cancelled...\");\t\tthis.status = false;\t}}
public class Engine {\tpublic float speed;\t\tpublic void accelerae (float value) {\t\tSystem.out.println(\"The car is accelerating...\");\t\tthis.speed += value;\t\tSystem.out.println(\"The current speed is : \" + speed + \"km/h\");\t}\tpublic void decelerate (float value) {\t\tSystem.out.println(\"The car is slowing...\");\t\tthis.speed += value;\t\tif(this.speed < 0) this.speed = 0;\t\tSystem.out.println(\"The current speed is : \" + speed + \"km/h\");\t}}
0 条评论
下一页