本文整理汇总了C#中Car.StartTheVehicle方法的典型用法代码示例。如果您正苦于以下问题:C# Car.StartTheVehicle方法的具体用法?C# Car.StartTheVehicle怎么用?C# Car.StartTheVehicle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Car
的用法示例。
在下文中一共展示了Car.StartTheVehicle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
ConsoleKeyInfo ch;
ConsoleKeyInfo ch1;
Vehicle choosen_car = new Car("", "", 0, false);
Vehicle car1 = new Car("Peugeot", "Blue", 120, false);
Vehicle car2 = new Car("Opel", "Black", 150, false);
Vehicle choosen_motorcycle = new Motorcycle("", "", 0, false);
Vehicle motorcycle1 = new Motorcycle("Yamaha", "Blue", 140, false);
Vehicle motorcycle2 = new Motorcycle("Harley Davidson", "Red", 170, false);
Vehicle choosen_powerboat = new Powerboat("", "", 0, false);
Vehicle powerboat1 = new Powerboat("Windboat", "White", 50, false);
Vehicle powerboat2 = new Powerboat("Shark boats", "Green", 60, false);
while (true)
{
Console.Clear();
Console.WriteLine("Choose the vehicle: ");
Console.WriteLine("");
Console.WriteLine("1 - Car");
Console.WriteLine("2 - Motorcycle");
Console.WriteLine("3 - Powerboat");
Console.WriteLine("0 - Exit");
ch = Console.ReadKey();
if (ch.KeyChar == '1')
{
while (true)
{
Console.Clear();
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 - Back");
ch1 = Console.ReadKey();
if (ch1.KeyChar == '1')
{
Console.Clear();
if (choosen_car.VehicleBrand == "")
choosen_car.StartTheVehicle();
else
choosen_car.StartTheVehicle(choosen_car);
}
if (ch1.KeyChar == '2')
{
Console.Clear();
Console.WriteLine("What car do you want to choose?");
Console.WriteLine("1 - Peugeot");
Console.WriteLine("2 - Opel");
ch1 = Console.ReadKey();
if (ch1.KeyChar == '1')
choosen_car = car1;
if (ch1.KeyChar == '2')
choosen_car = car2;
}
if (ch1.KeyChar == '3')
{
Console.Clear();
Console.WriteLine("What car do you want to fill?");
Console.WriteLine("1 - Peugeot");
Console.WriteLine("2 - Opel");
ch1 = Console.ReadKey();
if (ch1.KeyChar == '1')
car1.FuelTheVehicle(car1);
if (ch1.KeyChar == '2')
car2.FuelTheVehicle(car2);
}
if (ch1.KeyChar == '0')
break;
Console.ReadKey();
}
}
if (ch.KeyChar == '2')
{
while (true)
{
Console.Clear();
motorcycle1.Information();
motorcycle2.Information();
Console.WriteLine("");
Console.WriteLine("1 - Start the motorcycle");
Console.WriteLine("2 - Choose the motorcycle");
Console.WriteLine("3 - Fuel the motorcycle");
Console.WriteLine("0 - Back");
ch1 = Console.ReadKey();
if (ch1.KeyChar == '1')
{
Console.Clear();
if (choosen_motorcycle.VehicleBrand == "")
choosen_motorcycle.StartTheVehicle();
else
choosen_motorcycle.StartTheVehicle(choosen_motorcycle);
}
if (ch1.KeyChar == '2')
{
Console.Clear();
Console.WriteLine("What motorcycle do you want to choose?");
Console.WriteLine("1 - Yamaha");
//.........这里部分代码省略.........