本文整理汇总了C#中Vehicle.FuelTheCar方法的典型用法代码示例。如果您正苦于以下问题:C# Vehicle.FuelTheCar方法的具体用法?C# Vehicle.FuelTheCar怎么用?C# Vehicle.FuelTheCar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vehicle
的用法示例。
在下文中一共展示了Vehicle.FuelTheCar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
ConsoleKeyInfo ch;
Vehicle choosen_car = new Vehicle("", "", 0, "", false);
Vehicle car1 = new Vehicle("Peugeot", "Green", 120, "France", false);
Vehicle car2 = new Vehicle("Opel", "Black", 150, "Germany", false);
while (true)
{
Console.Clear();
Console.WriteLine("Vehicle type:");
Console.WriteLine(Vehicle.VehicleType);
Console.WriteLine("");
car1.Information();
car2.Information();
Console.WriteLine("");
Console.WriteLine("1 - Start the car");
Console.WriteLine("2 - Choose the car");
Console.WriteLine("3 - Fuel the car");
Console.WriteLine("0 - Exit");
ch = Console.ReadKey();
if (ch.KeyChar == '1')
{
Console.Clear();
if (choosen_car.CarBrand == "")
choosen_car.StartTheCar();
else
choosen_car.StartTheCar(choosen_car);
}
if (ch.KeyChar == '2')
{
Console.Clear();
Console.WriteLine("What car do you want to choose?");
Console.WriteLine("1 - Peugeot");
Console.WriteLine("2 - Opel");
ch = Console.ReadKey();
if (ch.KeyChar == '1')
choosen_car = car1;
if (ch.KeyChar == '2')
choosen_car = car2;
}
if (ch.KeyChar == '3')
{
Console.Clear();
Console.WriteLine("What car do you want to fill?");
Console.WriteLine("1 - Peugeot");
Console.WriteLine("2 - Opel");
ch = Console.ReadKey();
if (ch.KeyChar == '1')
car1.FuelTheCar(car1);
if (ch.KeyChar == '2')
car2.FuelTheCar(car2);
}
if (ch.KeyChar == '0')
break;
Console.ReadKey();
}
}