教练类Trainger.java
public class Trainger{
//完成某方法必备的物质载体
private Car car=new Car();
//类具备的功能
public void trainning(){
System.out.println("教练开始教学生练车");
car.runStraight();
car.runCurse();
car.runBehind();
System.out.println("教练教学员练车完毕");
}
}
车子类Car.java
public class Car{
public void runStraight(){
System.out.println("教练正在教学生走直线。。。。");
System.out.println("");
}
public void runCurse(){
System.out.println("教练正在教学生曲线行驶。。。。");
System.out.println("");
}
public void runBehind(){
System.out.println("教练正在教学生倒车入库。。。。");
System.out.println("");
}
}
Test.java
public class Test{
public static void main(String[] args) {
Trainger zhangsan =new Trainger();
zhangsan .trainning();
}
}
时间: 2024-10-10 04:27:04