阅读下列说明和Java代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】某软件公司欲开发一款汽车竞速类游戏,需要模拟长轮胎和短轮胎急刹车时在路面上留下的不同痕迹,并考虑后续能模拟更多种轮胎急刹车时的痕迹。现采用策略(Strategy)设计模式来实现该需求,所设计的类图如图5-1所示。 【Java代码】importjava.util.*;interfaceBrakeBehavior{public(1);/*其余代码省略*/}classLongWheelBrakeimplementsBrakeBehavior{publicvoidstop(){System.out.println("模拟长轮胎刹车痕迹!");}/*其余代码省略*/}classShortWheelBrakeimplementsBrakeBehavior{publicvoidstop(){System.out.println("模拟短轮胎刹车痕迹!");}/*其余代码省略*/}abstractclassCar{protected(2)wheel;publicvoidbrake(){(3);}/*其余代码省略*/}classShortWheelCarextendsCar{publicShortWheelCar(BrakeBehaviorbehavior){(4);}/*其余代码省略*/}classStrategyTest{publicstaticvoidmain(String[]args){BrakeBehaviorbrake=newShortWheelBrake();ShortWheelCarcar1=newShortWheelCar(brake);car1.(5);}}
1. void stop()2. BrakeBehavior3. wheel.stop()4. wheel=behavior5. brake()