示例#1
0
        public void Select(Motorbike selectedMotorbike)
        {
            bool exit = false;

            while (!exit)
            {
                Console.WriteLine("\nSelected Motorbike:");
                PrintInfo(selectedMotorbike, false);
                Console.WriteLine("Choose an option:");
                Console.WriteLine("\t1. Edit");
                Console.WriteLine("\t2. Delete");
                Console.WriteLine("\t3. Calculate fuel");
                Console.WriteLine("\t4. Refuel");
                Console.WriteLine("\t5. Passengers");
                Console.WriteLine("\t6. Back");

                switch (Console.ReadKey(true).KeyChar)
                {
                case '1':
                    MotorbikeEditConsoleView motorbikeEditConsoleView = new MotorbikeEditConsoleView(selectedMotorbike);
                    selectedMotorbike = motorbikeServicesObj.Update(motorbikeEditConsoleView.Load());
                    break;

                case '2':
                    Console.Write("Type vehicle name to confirm:");
                    if (Console.ReadLine() == selectedMotorbike.vehicleName)
                    {
                        motorbikeServicesObj.Delete(selectedMotorbike);
                        exit = true;
                    }
                    else
                    {
                        Console.WriteLine("Cancelled");
                    }
                    break;

                case '3':
                    Console.Write("Enter distance in miles: ");
                    Distance distance = new Distance();
                    distance.miles    = Convert.ToDecimal(Console.ReadLine());
                    selectedMotorbike = motorbikeServicesObj.CalculateFuel(selectedMotorbike, distance);
                    break;

                case '4':
                    selectedMotorbike = motorbikeServicesObj.Refuel(selectedMotorbike);
                    break;

                case '5':
                    MotorbikePassengerConsoleView motorbikePassengers = new MotorbikePassengerConsoleView(selectedMotorbike);
                    motorbikePassengers.Load();
                    break;

                case '6':
                    exit = true;
                    break;

                default:
                    Console.WriteLine("Invalid input");
                    break;
                }
            }
        }
 private void refuelButton_Click(object sender, System.EventArgs e)
 {
     motorbikeServicesObj.Refuel(GetSelectedMotorbike());
     FillMotorbikeList();
 }