using System;
using System.Collections.Generic;
using System.Text;
namespace _052_面对对象初级_小练习
{
public class Ticket
{
private double _distance;
public double Distance
{
get { return _distance; }
}
public Ticket(double distance)
{
if (distance < 0)
{
distance = 0;
}
this._distance = distance;
}
private double _price;
public double Price
{
get
{
if (Distance > 0 && Distance < 100)
{
return Distance * 1.0;
}
else if (Distance >= 100 && Distance < 200)
{
return Distance * 0.95;
}
else if (Distance >= 200 && Distance < 300)
{
return Distance * 0.9;
}
else
{
return Distance * 0.8;
}
//return _price;
}
}
public void ShowTicket()
{
Console.WriteLine("{0}公里,需要{1}元", Distance, Price);
}
}
}