问题详情

阅读下列说明、图和Java代码,将应填入(n)处的字句写在对应栏内。

【说明】

已知对某载客车辆(Car)进行类建模,如图7-1所示,其中类Engine表示发动机引擎,类Wheel表示车轮,类Body表示车身,类Driver表示司机,类Passenger表示乘客。

【Java代码】

class Body{ //此处代码省略 ); //车身类

class Passenger{ //此处代码省略 )/ //乘客类

class Wheel{ //此处代码省略 ); //车轮类

class Driver{ //司机类

public String name; //表示第几路公交车司机

public Driver(String driverName){name = driverName/) //构造函数

};

class Engine{//引擎类

public String engineNo;//引擎编号

public Engine(String engineNo){this.engineNo=engineNo;)//构造函数

};

public class Car{//汽车类

static final int(1)=7; //定义最多载客数

static final int MAX WHEELS =5; //定义最多轮胎数

protected Engine engine;

protected Driver driver;

protected Body body=new Body();

protected Wheel[] wheels;

protected Passenger[]passengers;

public Car(Driver driver){ //构造函数

(2).driver=driver;

engine=new Engine("TX6536型号引擎");

wheels=new Wheel[MAX WHEELS];

passengers=new Passenger[MAX_PASSENGERS];

for(int index=0;index<MAX_WHEELS;index++){

wheels[index]=new Wheel();

}

for(int index=0;index<MAX_PASSENGERS;index++){

passengers[index]=null;

}

}

int getPassengerNumber(){//获取车上乘客数量

//此处代码省略

}

void getOnPassenger(Passenger aPassenger){//乘客上车

//此处代码省略

}

void run(){ //开车

if((3)){System.out.println("司机尚未上车!");return;}

//此处代码省略

}

public static void main(String args[]){

Driver driver=new Driver("第五路公交车司机");

Car car=new Car((4));

for (int index = 0 ; index < MAX_PASSENGERS; index ++)

car.getOnPassenger((5) Passenger());

car.run();

}

}

未搜索到的试题可在搜索页快速提交,您可在会员中心"提交的题"快速查看答案。 收藏该题
查看答案

相关问题推荐

在C++语言中每个类都有一个______指针,该指针指向正在调用成员函数的对象。

以下程序运行后的输出结果是()。 main() {int a=3,b=4,c=5,t=79; if(b<a&&a<C)t=a;a=c;c=t; if(a<c&&b<C)t=b;b=a;a=t;printf("%d%d%dn",a,b,C); }

在IKE执行密钥交换时(建立主要模式SA的阶段),通信双方需要验证对方的身份,Windows2003中支持(6)、(7)和(8)验证。

语句int*i=newintl[10];,释放指针i的语句是______。

在整个VPN通信中,主要有(12)和(13)两种VPN通信方式,而后者又包括“IntranetVPN(企业内联VPN)”和“ExtranetVPN(企业外联VPN)”。

联系客服 会员中心
TOP