父类的构造方法 在 子类的构造方法 之前调用
父类如果是无参构造方法则子类构造方法可以不写 :base()
namespace ConsoleApplication2.面向对象
{
class Plane
{
protected float width;
protected float height;
public float x;
public float y;
protected string bgImage;
protected float speed;
protected int hp;
this.width = width;
this.height = height;
this.x = x;
this.y = y;
this.bgImage = bgImage;
this.speed = speed;
}
class MyPlane : Plane {
public MyPlane(float w,float h,float x,float y,string bgimg,float s):base(w,h,x,y,bgimg,s)
{
hp=1;
}
}