求教一个C#的题: 写一个Ticket的类,有一个距离(属性(只读,在构造方法中赋值),不能是负数,还有一个

2022-08-12 社会 59阅读
public class Ticket
{
private int _Distance;
private double _Price;

public int Distance {
get {
return this._Distance;
}
}

public double Price {
set {
this._Price = value;
}
get {
if (this.Distance < 100) {
return (double)this.Distance;
}
else if (this.Distance < 200) {
return (double)this.Distance * .9;
}
else {
return (double)this.Distance * 8;
}
}
}
}
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com