Beispiel #1
0
        public static void AddPlayer(string[] input, List <Team> teams)
        {
            string team   = input[1];
            string player = input[2];

            int[]  stats     = input.Skip(3).Select(int.Parse).ToArray();
            Stats  newStats  = new Stats(stats[0], stats[1], stats[2], stats[3], stats[4]);
            Player newPlayer = new Player(player, newStats);

            ValidateTeam.TeamValidation(input[1], teams);
            Team toAdd = teams.Find(x => x.Name == team);

            toAdd.AddPlayer(newPlayer);
        }
Beispiel #2
0
        public void Run()
        {
            string input = string.Empty;

            while ((input = Console.ReadLine()) != "END")
            {
                try
                {
                    string[] inputArr = input
                                        .Split(";", StringSplitOptions.RemoveEmptyEntries).ToArray();

                    if (inputArr[0] == "Team")
                    {
                        Team newTeam = new Team(inputArr[1]);
                        teams.Add(newTeam);
                    }

                    else if (inputArr[0] == "Add")
                    {
                        ValidateTeam.TeamValidation(inputArr[1], teams);
                        BuyingPlayers.AddPlayer(inputArr, teams);
                    }

                    else if (inputArr[0] == "Remove")
                    {
                        ValidateTeam.TeamValidation(inputArr[1], teams);
                        SellingPlayer.RemovePlayer(teams, inputArr);
                    }

                    else if (inputArr[0] == "Rating")
                    {
                        ValidateTeam.TeamValidation(inputArr[1], teams);
                        Team team = teams.Find(x => x.Name == inputArr[1]);
                        Console.WriteLine($"{team.Name} - {team.Rating}");
                    }
                }
                catch (Exception)
                {
                }
            }
        }