Example #1
0
        public static void Start(Taxi taxi)
        {
            Console.WriteLine("Taxi contains:\r\n");

            ShowData(taxi.Cars);

            while (true)
            {
                Console.WriteLine("\r\nPlease choose what do you want to do? " +
                                  "\r\n 1. Show all items in Taxi " +
                                  "\r\n 2. Get full price " +
                                  "\r\n 3. Get full load capacity " +
                                  "\r\n 4. Sort by property " +
                                  "\r\n 5. Find cars by property " +
                                  "\r\n 6. Exit\r\n");
                int choose;
                if (int.TryParse(Console.ReadLine(), out choose))
                {
                    switch (choose)
                    {
                    case 1:
                        Console.Clear();
                        Console.WriteLine("Taxi contains:\r\n");
                        ShowData(taxi.Cars);
                        break;

                    case 2:
                        Console.Clear();
                        Console.WriteLine("\nTotal cost of the taxi: {0}", taxi.GetTotalCost());
                        Console.WriteLine("-----------------------------");
                        break;

                    case 3:
                        Console.Clear();
                        Console.WriteLine("\nTotal load capacity of the taxi: {0}", taxi.GetTotalLoadCapacity());
                        Console.WriteLine("-----------------------------");
                        break;

                    case 4:
                        SortByProperty(taxi);
                        break;

                    case 5:
                        FindByProperty(taxi);
                        break;

                    case 6:
                        return;

                    default:
                        Console.Clear();
                        Console.WriteLine("Wrong input data");
                        Console.WriteLine("-----------------------------");
                        break;
                    }
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine("Wrong input data");
                    Console.WriteLine("-----------------------------");
                }
            }
        }