示例#1
0
 public static void AddMatches(Match match)
 {
     if (CheckMatchExists(match))
     {
         matches.Add(match);
     }
 }
示例#2
0
文件: League.cs 项目: Gab42/OOP
 public static void AddMatch(Match match)
 {
     if (MatchAddCheck(match))
     {
         throw new InvalidOperationException("Match already exists in the league!");
     }
     Matches.Add(match);
 }
示例#3
0
 public static void AddMatches(Match match)
 {
     if (AddMatchesChecker(match))
     {
         throw new InvalidOperationException("Match already exists in the league.");
     }
     matches.Add(match);
 }
示例#4
0
        private static bool CheckMatchExists(Match match)
        {
            if (matches.Any(m => m.Id == match.Id))
            {
                return false;
            }

            return true;
        }
 private static void AddMatch(int id, string homeTeamName, string awayTeamName, string score)
 {
     Team t = new Team(homeTeamName, "     ", new DateTime(1850, 1, 1));
     t.Name = homeTeamName;
     Team s = new Team(awayTeamName, "        ", new DateTime(1850, 1, 1));
     s.Name = awayTeamName;
     Score sc;
     string[] scc = score.Split(' ');
     sc = new Score(int.Parse(scc[0]), int.Parse(scc[1]));
     Match match = new Match(t, s, sc, id);
     if (League.CheckIfMatchExist(match))
     {
         throw new InvalidOperationException("This match already exist");
     }
     League.AddMatch(match);
     Console.WriteLine("Match - Confirmed");
 }
示例#6
0
        private static void AddMatch(string homeTeamName, string awayTeamName, string idStr, string homeTeamGoals, string awayTeamGoals)
        {
            if (League.Teams.All(t => t.Name != homeTeamName))
            {
                throw new InvalidOperationException("Team name");
            }

            if (League.Teams.All(t => t.Name != awayTeamName))
            {
                throw new InvalidOperationException("Team name");
            }

            var homeTeam = League.Teams.First(t => t.Name == homeTeamName);
            var awayTeam = League.Teams.First(t => t.Name == awayTeamName);
            var id = int.Parse(idStr);
            var score = new Score(int.Parse(homeTeamGoals), int.Parse(awayTeamGoals));
            var match = new Match(homeTeam, awayTeam, id, score);
            League.AddMatches(match);
            Console.WriteLine("Match with ID: " + idStr + " has been added succesfully");
        }
示例#7
0
文件: League.cs 项目: Gab42/OOP
 private static bool MatchAddCheck(Match match)
 {
     return Matches.Any(m => m.Id == match.Id);
 }
示例#8
0
 public static bool AddMatchesChecker(Match match)
 {
     return Matches.Any(m => m.Id == match.Id);
 }