namespace ConsoleApplication4
{
public class Travel
{
private int tourCost = 0;
private String tourLocation;
public int TourCost
{
get
{
if (tourLocation == "北京")
return tourCost = 1000;
else if (tourLocation == "上海")
return tourCost = 1500;
else if (tourLocation == "广州")
return tourCost = 2000;
else
return 0;
}
}
public String TourLocation
{
get
{
return tourLocation;
}
set
{
if (value != "北京" && value != "上海" && value != "广州")
tourLocation = null;
else
tourLocation = value;
}
}
class Program
{
static void Main(string[] args) //每次输入地点前都需要输入go 不知怎么解决
{
Console.WriteLine("请输入go开始程序,输入Q/q退出程序!");
String testString = Console.ReadLine();
while(testString!="Q"&&testString!="q")
{
Travel testobj = new Travel();
testobj.TourLocation =Console.ReadLine();
Console.WriteLine(testobj.TourCost);
Console.ReadLine();
}
}
}
}
}
每次输入地点前都需要输入一次go 怎样修改能够只输入一次(或者不输入)go就一直执行下去
谢谢了
谢了
本回答被提问者采纳