コード例 #1
0
 public bool RegisterSportsman(Sportsman sportsman)
 {
     if (Sportsmen.Contains(sportsman))
     {
         return(false);
     }
     Sportsmen.Add(sportsman);
     return(true);
 }
コード例 #2
0
        public bool AddMedalToSportsman(Sportsman sportsman, MedalType medalType)
        {
            var newMedal = new MedalSportsman(sportsman, medalType);

            if (Medals.Contains(newMedal))
            {
                return(false);
            }
            Medals.Add(newMedal);
            return(true);
        }
コード例 #3
0
 public bool RemoveSportsman(Sportsman sportsman)
 {
     if (Sportsmen.Contains(sportsman))
     {
         if (Medals.Any(m => m.Sportsman == sportsman))
         {
             throw new Exception($"{sportsman} can not be removed because he/she has involved in a competition");
         }
         else
         {
             Sportsmen.Remove(sportsman);
             return(true);
         }
     }
     return(false);
 }
コード例 #4
0
 public void ChangeSportsmanMedal(Sportsman sportsman, MedalType medalType)
 {
     Medals.FirstOrDefault(m => m.Sportsman == sportsman).ChangeMedalType(medalType);
 }
コード例 #5
0
 public void RemoveMedalToSportsman(Sportsman sportsman)
 {
     Medals.Remove(Medals.FirstOrDefault(m => m.Sportsman == sportsman));
 }
コード例 #6
0
ファイル: MedalSportsman.cs プロジェクト: TorideX/Olympics
 public MedalSportsman(Sportsman sportsman, MedalType medalType)
 {
     Sportsman = sportsman;
     MedalType = medalType;
 }