Ejemplo n.º 1
0
    void setScoreStrategy(int option)
    {
        switch (option)
        {
        case 1:    //normal score
            strategy = new LatestScore(text);
            break;

        case 2:    //high score
            strategy = new HighScore(text);
            break;

        default:
            break;
        }
    }
Ejemplo n.º 2
0
        public void TestCompareScores(int c1, int p1, int c2, int p2, ScoreStrategy strategy, int expected)
        {
            var firstScore  = new Score(new PlayerScore(c1), new PlayerScore(p1));
            var secondScore = new Score(new PlayerScore(c2), new PlayerScore(p2));

            foreach (bool vortex in new[] { false, true })
            {
                foreach (WordStrategy word in Enum.GetValues(typeof(WordStrategy)))
                {
                    foreach (Fix oneFixes in new[] { Fix.None, Fix.All })
                    {
                        foreach (Fix twoMoreFixes in new[] { Fix.None, Fix.All })
                        {
                            var comparer = new PlayInfoComparer(strategy, word);
                            var first    = new PlayInfo(vortex, firstScore, oneFixes, twoMoreFixes);
                            var second   = new PlayInfo(vortex, secondScore, oneFixes, twoMoreFixes);
                            Assert.AreEqual(expected, comparer.Compare(first, second));
                            Assert.AreEqual(-expected, comparer.Compare(second, first));
                            TestSort(comparer, first, second, expected);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public PlayInfoComparer(ScoreStrategy scoreStrategy, WordStrategy wordStrategy)
 {
     this.scoreStrategy = scoreStrategy;
     this.wordStrategy  = wordStrategy;
 }