コード例 #1
0
        public void Run()
        {
            _running = true;
            while (_running)
            {
                Console.WriteLine("Vad vill du göra?");
                Console.WriteLine("0 - Avsluta");
                Console.WriteLine("1 - Lägga till en ny resa");
                Console.WriteLine("2 - Anmäl en person till nästa resa");
                Console.WriteLine("3 - Visa resa");
                Console.WriteLine("4 - Visa alla resor");

                var input = Console.ReadLine().ToLower();
                if (input == "0" || input == "avsluta")
                {
                    _running = false;
                }
                else
                {
                    if (input == "1" || input == "lägga till resa")
                    {
                        Console.WriteLine("Lägga till resa");
                    }
                    else if (input == "2" || input == "lägga till person")
                    {
                        SignPerson();
                    }
                    else if (input == "3" || input == "nästa")
                    {
                        Print(Journeys.Next());
                    }

                    else if (input == "4" || input == "lägga till person")
                    {
                        Journeys.GetAll().ToList().ForEach(Print);

                        PressAnyKey();
                    }
                    else
                    {
                        Console.WriteLine($"Okänt kommando: {input}");
                    }
                }
            }
        }