Пример #1
0
        public void InsertPlayer(string input, List <Player> playerList)
        {
            bool listPlayer = true;

            if (input.ToLower() == "list")
            {
                DisplayList PlayerList = new DisplayList();
                PlayerList.ListAllPlayers(playerList);
                listPlayer = false;
                Console.WriteLine("");
            }

            if (String.IsNullOrWhiteSpace(input) == true)
            {
                Console.WriteLine("Enter a valid playername");
                Console.WriteLine("");
                listPlayer = false;
            }


            if (input.Length > maxNameLenght)
            {
                Console.WriteLine("Player Name has to be" + maxNameLenght + "caracters or less");
                Console.WriteLine("");
                listPlayer = false;
            }

            if (input.ToLower() == "start")
            {
                listPlayer = false;
            }

            foreach (Player player in playerList)
            {
                if (player.Name == input)
                {
                    listPlayer = false;
                    Console.WriteLine("Spieler mit diesem Namen wurde bereits hinzugefügt");
                    Console.WriteLine("");
                }
            }

            if (listPlayer == true)
            {
                playerList.Add(new Player()
                {
                    Name = input, Wins = 0, Ties = 0, Loses = 0
                });
            }
        }