예제 #1
0
        public Result Run()
        {
            Result      result      = new Result(coin, sample, face);
            FlipHistory flipHistory = new FlipHistory();

            int consecutiveCount = 0;

            for (int i = 0; i < sample; i++)
            {
                Coin.FACE face = coin.Flip();
                flipHistory.Log(face);
                consecutiveCount = (face == this.face) ? consecutiveCount + 1 : 0;
                result.IncrementCountsUpToValue(consecutiveCount);

                Result.ResultType type = (face == Coin.FACE.HEADS ? Result.ResultType.HEADS : Result.ResultType.TAILS);
                result.AddCount(type);
            }
            result.AddHistory(flipHistory);
            return(result);
        }