コード例 #1
0
        /// Creates a new <see cref="Player"/> with the giving player name.
        public void CreateNewPlayer()
        {
            Log.Info("Creating new player.");
            Console.WriteLine("\nEnter the name of the new player:");
            Console.Write("Player Name: ");
            string playerName = Console.ReadLine();

            if (!string.IsNullOrEmpty(playerName) && BusinessLogic.AddNewPlayer(playerName))
            {
                Console.WriteLine($"Successfully created \"{playerName}\" as a new player!");
            }
            else
            {
                Console.WriteLine($"Failed to create \"{playerName}\" as a new player...");
            }
        }
コード例 #2
0
        /// <summary>
        /// Creates a new <see cref="Player"/> and checks to see if teams not selected(-1) then simply add it, otherwise,
        /// assign the new player to the selected <see cref="Team"/>.
        /// </summary>
        public void CreatePlayer()
        {
            Log.Info("Creating new player.");
            int tSelIndex = _view.TeamSelectedIndex;

            if (tSelIndex == -1) // -1 means nothing selected.
            {
                BusinessLogic.AddNewPlayer(_view.NameText);
            }
            else
            {
                Team team = _view.TeamsComboBox[tSelIndex].ToTeam();
                if (team != null)
                {
                    BusinessLogic.AddNewPlayer(_view.NameText, team.Id);
                }
            }
        }