我正在制作一个程序,其中有一些球在弹跳,但现在我想继承该类并使新的类无法设置它的速度
我已经尝试过了,但这没有任何作用
public class Ball {
public Ball(double posX, double posY, double rad, Vector vel) {
Pos = new Point(posX, posY);
Rad = rad;
Vel = vel;
}
public double Rad { get; set; }
public Point Pos { get; set; }
public Vector Vel { get; set; }
}
public class StaticBall : Ball {
public StaticBall(double posX, double posY, double rad)
: base(posX, posY, rad, new Vector(0, 0)) {
}
public Vector Vel {
get { return Vel; }
set { Vel = Vel; }
}
}
我该怎么做?