Source

RockPaperScissors / RockPaperScissors / SingleRoundStrategy.cs

Kevin Berridge c3af1d3 








Kevin Berridge ac8afba 
Kevin Berridge c3af1d3 
Kevin Berridge ac8afba 
Kevin Berridge c3af1d3 

Kevin Berridge ac8afba 
Kevin Berridge c3af1d3 
Kevin Berridge 2dec106 

Kevin Berridge c3af1d3 
Kevin Berridge ac8afba 
Kevin Berridge 2dec106 
Kevin Berridge ac8afba 
Kevin Berridge 2dec106 
Kevin Berridge ac8afba 

Kevin Berridge 2dec106 
Kevin Berridge ac8afba 
Kevin Berridge c3af1d3 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RockPaperScissors
{
  public class SingleRoundStrategy : IShouldPlayAgain, IKnowWhoWon
  {
    public bool ShouldPlayAgain( List<Winner> gameResults )
    {
      return FindFirstWinner( gameResults ) == Winner.Draw;
    }

    public Winner GetWhoWon( List<Winner> gameResults )
    {
      return FindFirstWinner( gameResults );
    }

    Winner FindFirstWinner( List<Winner> gameResults )
    {
      if ( gameResults == null || gameResults.Count == 0 ) return Winner.Draw;

      foreach ( Winner p in gameResults ) // find first winner
        if ( p != Winner.Draw ) return p;

      return Winner.Draw;
    }
  }
}