阅读下列程vehicle.cs回答相关问题

来源:百度知道 编辑:UC知道 时间:2024/06/06 07:34:06
1.成员weight的属性是什么,它在那些类中起作用?成员car.passengers的询问属性是什么,在那些类中起作用?
2.Wheels和wheels有何关系?
3.轿车实例c1包含那些可询问属性和方法?
4.第43行实例v1.speak()的输出结果为:

1.using System;
2.using System.windows.forms;
3.Class Vehicle
4.{private int wheels;
5.protected float weight;
6.public int wheels
7.{get { return wheels;}
8.set {if(value>0)wheels=value;}}
9.public vehicle(int w,float y)
10.{wheels=w;weight=y;}
11.public virtual string Speak()
12.{ return(“the w vehicle is speaking!\r\h”);}
13.}
14.class Car:vehicle
15.{int passengers;
16.public car(int w,float g,int p):base(w,g)
17.{passengers=p;}
18.public override string speak()
19.{return(“the car is speaking:Di-di!\r\n”);}
20.}
21.class Truck vehicle
22.
23.float load;
24.public Truck(int w,float g,int p,float 1):base(w,g)
25.{passengers=p;load=1;}
26.public override string Speak()
27.{st

帮你整理程序快累死我了,整理好的程序如下

using System;
using System.Windows.Forms;
class Vehicle
{
private int wheels;
protected float weight;
public int Wheels
{
get { return wheels; }
set { if (value > 0)wheels = value; }
}
public Vehicle(int w, float y)
{
wheels = w; weight = y;
}
public virtual string Speak()
{
return ("the w vehicle is speaking!\r\n");
}
}

class Car : Vehicle
{
int passengers;
public Car(int w, float g, int p)
: base(w, g)
{ passengers = p; }
public override string Speak()
{ return ("the car is speaking:Di-di!\r\n"); }
}

class Truck : Vehicle
{
float load;
public Truck(int w, float g, int p, float l)
: base(w, g)
{ passengers = p;