コード例 #1
0
ファイル: MatchDay.cs プロジェクト: thelpi/UAFEP
        /// <summary>
        /// Plays every non-played match of the instance.
        /// </summary>
        /// <exception cref="InvalidOperationException">Already played.</exception>
        public void Play()
        {
            if (Status == MatchDayStatus.Complete)
            {
                throw new InvalidOperationException("Already played.");
            }

            foreach (var match in Matches.Where(m => !m.Played))
            {
                match.Play();
            }
            Status = MatchDayStatus.Complete;
        }
コード例 #2
0
ファイル: MatchDay.cs プロジェクト: thelpi/UAFEP
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="matches">Array of <see cref="Match"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="matches"/> is <c>Null</c>.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="matches"/> is empty.</exception>
        /// <exception cref="ArgumentException">Matches list contains null.</exception>
        public MatchDay(params Match[] matches)
        {
            if (matches == null)
            {
                throw new ArgumentNullException(nameof(matches));
            }

            if (matches.Length == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(matches), 0, "Matches list is empty.");
            }

            if (matches.Contains(null))
            {
                throw new ArgumentException("Matches list contains null.", nameof(matches));
            }

            Matches = new List <Match>(matches);
            Status  = MatchDayStatus.Pending;
        }