示例#1
0
        static void Main(string[] args)
        {
            Scoreboard board = new Scoreboard();

            ShowStatus points = new ShowStatus(board.PointsAwarded);
            ShowStatus hit    = new ShowStatus(board.TargetHit);

            ShowStatus display = points;

            display += hit;

            CalculateScore getScore;
            int            time    = 60;
            int            targets = 20;

            getScore = new CalculateScore(Scoreboard.CalculateAdultScore);
            Console.WriteLine("Adult score: {0}", getScore(time, targets));

            getScore = null;

            getScore = new CalculateScore(Scoreboard.CalculateChildScore);
            Console.WriteLine("Child score: {0}", getScore(time, targets));

            getScore = null;

            display();

            display -= hit;
            display  = null;

            Console.ReadKey();
        }
        public void Given_I_have_four_cards_with_the_value_of_5_3_6_and_4_I_expect_the_value_returned_is_18()
        {
            // Given I have 4 cards
            // And the values are 5, 3, 6 and 4
            List <Card> cards = new List <Card>()
            {
                new Card
                {
                    Value = "5"
                },
                new Card
                {
                    Value = "3"
                },
                new Card
                {
                    Value = "6"
                },
                new Card
                {
                    Value = "4"
                }
            };

            // When I call the calculator score method with list of cards
            // And I pass in a card value converter
            ICalculateScore calculateScore = new CalculateScore(new ConvertCardValue(), new ConvertStringToInt());
            int             result         = calculateScore.CalculateTotalCardScore(cards);

            // Then I should expected the values to be 18.
            Assert.AreEqual(18, result);
        }
        public void Given_I_have_two_cards_with_the_value_of_5_and_Queen_I_expect_the_value_returned_is_15()
        {
            // Given I have 2 cards
            // And the values are 5 and Queen
            List <Card> cards = new List <Card>()
            {
                new Card
                {
                    Value = "5"
                },

                new Card
                {
                    Value = "queen"
                }
            };

            // When I call the calculator score method with list of cards
            // And I pass in a card value converter
            ICalculateScore calculateScore = new CalculateScore(new ConvertCardValue(), new ConvertStringToInt());
            int             result         = calculateScore.CalculateTotalCardScore(cards);

            // Then I should expected the values to be 15.
            Assert.AreEqual(15, result);
        }
示例#4
0
 public Pacman(int x, int y, Map zemelapis, CalculateScore calculateSc)
 {
     PacmanX     = x;
     PacmanY     = y;
     Zemelapis   = zemelapis;
     CalculateSc = calculateSc;
 }
        public void Given_I_have_three_cards_with_the_value_of_5_7_and_10_I_expect_the_value_returned_is_22()
        {
            // Given I have 3 cards
            // And the values are 5, 7 and 10
            List <Card> cards = new List <Card>()
            {
                new Card
                {
                    Value = "5"
                },
                new Card
                {
                    Value = "7"
                },
                new Card
                {
                    Value = "10"
                }
            };

            // When I call the calculator score method with list of cards
            // And I pass in a card value converter
            ICalculateScore calculateScore = new CalculateScore(new ConvertCardValue(), new ConvertStringToInt());
            int             result         = calculateScore.CalculateTotalCardScore(cards);

            // Then I should expected the values to be 22.
            Assert.AreEqual(22, result);
        }
        public void Given_I_have_4_cards_the_card_value_converter_should_be_only_called_four_times()
        {
            // Given I have four cards
            // And I call the convertCardValueMock value converter
            // And I call the convertCardValueMock string converter
            List <Card> cards = new List <Card>
            {
                new Card(),
                new Card(),
                new Card(),
                new Card()
            };

            Mock <IConvertCardValue>   convertCardValueMock   = new Mock <IConvertCardValue>();
            Mock <IConvertStringToInt> convertStringToIntMock = new Mock <IConvertStringToInt>();

            // When I pass in the convertCardValueMock object
            // And call the CalculateTotalCardScore method
            // And I call the convertCardValueMock string converter
            ICalculateScore calculateScore = new CalculateScore(convertCardValueMock.Object, convertStringToIntMock.Object);

            calculateScore.CalculateTotalCardScore(cards);

            // Then I verify then card value converter is only called four times.
            convertCardValueMock.Verify(m => m.ConvertValueFromCard(It.IsAny <string>()), Times.Exactly(4));
            // And I verify the string to int converter is only ever called four times.
            convertStringToIntMock.Verify(m => m.ConvertValue(It.IsAny <string>()), Times.Exactly(4));
        }
示例#7
0
    private int m_Penalty;       //negative score when the customer is served incorrect order and leaves

    #endregion

    #region UNITY_METHODS
    /// <summary>
    /// Assigning the instance for singelton.
    /// </summary>
    private void Awake()
    {
        if (m_Instance == null)
        {
            m_Instance = this;
        }
    }
示例#8
0
 // Use this for initialization
 void Start()
 {
     calScore         = FindObjectOfType <CalculateScore>();
     monsterCount     = calScore.score;
     monstertext.text = monsterCount.ToString();
     Destroy(calScore.gameObject);
 }
示例#9
0
    public void PutDownCube()
    {
        this.enabled = false;

        if (HitInfo.collider == null)
        {
            Destroy(this.gameObject);
            hittedObject.GetComponent <Renderer>().material.color = hittedObjectColor;
            return;
        }

        if (mv == true)
        {
            this.transform.position = new Vector3(HitInfo.collider.gameObject.transform.position.x,
                                                  HitInfo.collider.gameObject.transform.position.y + 0.5f,
                                                  HitInfo.collider.gameObject.transform.position.z);
            // this.transform.position = HitInfo.collider.gameObject.transform.position;
            mv = false;
            hittedObject.GetComponent <Renderer>().material.color = hittedObjectColor;
            if (HitInfo.collider.gameObject.tag == "road")
            {
                Destroy(this.gameObject);
            }

            //this.transform.position
            //= new Vector3(HitInfo.collider.gameObject.transform.position.x,
            //HitInfo.collider.gameObject.transform.position.y + 0.7f,
            //HitInfo.collider.gameObject.transform.position.z);
            CalculateScore.Calculate(GetComponent <Building>());
        }
    }
示例#10
0
 void OnTriggerEnter(Collider col)
 {
     Debug.Log(col.gameObject.name);
     if (col.gameObject.tag == "Bonus")
     {
         CalculateScore.correctPrice(Price.BONUS);
         BonusSelecter(col.name);
     }
 }
        /// <summary>
        /// Perform a score calculation for the specified genome.
        /// </summary>
        /// <param name="g">The genome to calculate for.</param>
        public void PerformScoreCalculation(IGenome g)
        {
            if (g.Organism is IContextClearable)
            {
                ((IContextClearable)g.Organism).ClearContext();
            }
            double score = CalculateScore.CalculateScore(g);

            g.Score = score;
        }
示例#12
0
        public GameController()
        {
            Zemelapis = new Map();
            Score     = new CalculateScore(Zemelapis);
            _pacman   = new Pacman(5, 5, Zemelapis, Score);
            _ghost    = new Ghost(1, 5, Zemelapis);

            Zemelapis.ZaidimoLenta[_pacman.PacmanX, _pacman.PacmanY] = GameObjects.Pacman;
            Zemelapis.ZaidimoLenta[_ghost.GhostX, _ghost.GhostY]     = GameObjects.Vaiduoklis;
            _draw = new Draw(Zemelapis);
        }
示例#13
0
        public void Roll(int pins)
        {
            if (IsGameEnd)
            {
                return;
            }

            if (lastFrame.IsFrameCompleted)
            {
                _frames.Add(new Frame());
                lastFrame = _frames.Last();
            }
            lastFrame.PinsKnocked.Add(pins);
            CalculateScore.ScoreCalculation(lastFrame);
        }
示例#14
0
        public void Given_I_Have_a_list_of_1_frame_then_i_will_get_back_8()
        {
            //given i have a list of 1 frame
            List <FrameObject> frame = new List <FrameObject>();

            //and the frame values are 8
            frame.Add(new FrameObject {
                score = 8
            });
            //when i call the calculate score method
            ICalculateScore calculateScore = new CalculateScore();
            int             total          = calculateScore.CalculateTotalScore(frame);

            //then i will get back the total score that is 8
            Assert.AreEqual(8, total);
        }
示例#15
0
文件: Form1.cs 项目: Daoi/Scrabble
        private void btnEndTurn_Click(object sender, EventArgs e)
        {
            string        words        = VerifyBoardState.VerifyBoard(gameBoard, placements, wc, ib);
            StringBuilder invalidWords = new StringBuilder("The following invalid words were found: ");

            if (words.Contains("!"))//Turn unsuccesful, inform player of incorrect words.
            {
                string[] split = words.Split(' ');
                foreach (string str in split)
                {
                    if (str.Contains("!"))
                    {
                        invalidWords.Append(str.TrimEnd('!') + " ");
                    }
                }

                MessageBox.Show(invalidWords.ToString() + " please retake your turn.");
            }
            else//Turn succuesful, draw new tiles and save hand. Calculate Score.
            {
                List <char> letters = words.ToList();
                //Scoring
                foreach (string s in tilesThisTurn)
                {
                    letters.Remove(char.Parse(s));
                }
                letters.ForEach(c =>
                                { if (char.IsLetter(c))
                                  {
                                      score += CalculateScore.CalculateNonPlacedTileScore(c);
                                  }
                                  ; });

                currentPlayer.updateScore(score * scoreMultiplier);

                MessageBox.Show("The following words were formed: " + words + $" For {score * scoreMultiplier} points", "Words formed and score");

                List <Button> emptyTiles = pnlTiles.Controls.OfType <Button>().ToList().FindAll(btn => btn.Text.Equals(""));
                string[]      newTiles   = currentGame.drawTiles(emptyTiles.Count);
                for (int i = 0; i < newTiles.Length; i++)
                {
                    emptyTiles[i].Text = newTiles[i];
                }
                EndTurn();
            }
        }
    public bool PutDownCube()
    {
        this.enabled = false;
        _highLightObj.gameObject.SetActive(false);

        if (_currentOnCell == null ||
            _currentOnCell.Building != null ||
            !_currentOnCell.CanBuildBuilding)
        {
            return(false);
        }

        _currentOnCell.BuildBuilding(GetComponent <Building>());
        CalculateScore.Calculate(GetComponent <Building>());

        return(true);
    }
示例#17
0
        public void TestBowling_AllStrikes()
        {
            //Assemble
            HardcodedPinPhysics physics = new HardcodedPinPhysics(balls_AllStrikes);
            GoBowling           bowl    = new GoBowling(physics);

            //Act
            int pinsNockedDown01 = bowl.ThrowBall(1);
            int pinsNockedDown02 = bowl.ThrowBall(1);
            int pinsNockedDown03 = bowl.ThrowBall(1);
            int pinsNockedDown04 = bowl.ThrowBall(1);
            int pinsNockedDown05 = bowl.ThrowBall(1);
            int pinsNockedDown06 = bowl.ThrowBall(1);
            int pinsNockedDown07 = bowl.ThrowBall(1);
            int pinsNockedDown08 = bowl.ThrowBall(1);
            int pinsNockedDown09 = bowl.ThrowBall(1);
            int pinsNockedDown10 = bowl.ThrowBall(1);
            int pinsNockedDown11 = bowl.ThrowBall(2);
            int pinsNockedDown12 = bowl.ThrowBall(3);

            //Assert
            Assert.AreEqual(10, pinsNockedDown01);
            Assert.AreEqual(10, pinsNockedDown02);
            Assert.AreEqual(10, pinsNockedDown03);
            Assert.AreEqual(10, pinsNockedDown04);
            Assert.AreEqual(10, pinsNockedDown05);
            Assert.AreEqual(10, pinsNockedDown06);
            Assert.AreEqual(10, pinsNockedDown07);
            Assert.AreEqual(10, pinsNockedDown08);
            Assert.AreEqual(10, pinsNockedDown09);
            Assert.AreEqual(10, pinsNockedDown10);
            Assert.AreEqual(10, pinsNockedDown11);
            Assert.AreEqual(10, pinsNockedDown12);

            CalculateScore calculate  = new CalculateScore();
            int?           totalScore = calculate.TotalScore(bowl.Frames, bowl.Balls, 9);

            Assert.AreEqual(300, totalScore.Value);

            totalScore = calculate.TotalScore(bowl.Frames, bowl.Balls, 5);
            Assert.AreEqual(180, totalScore.Value);

            totalScore = calculate.TotalScore(bowl.Frames, bowl.Balls, 0);
            Assert.AreEqual(30, totalScore.Value);
        }
        public IActionResult Post([FromBody] ViewModels.ParticipantViewModel Participantvalues)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            CertifiedVals = ScoreValLogic.Certify(Participantvalues);
            GeoLocProps GetGeoLocation = getGeoLocations().Result;
            string      Address        = string.Format("{0} {1} {2}", Participantvalues.City, " , ", Participantvalues.State);
            MapPoint    mapCords       = latlangofAddr(Address, GetGeoLocation.Latitude, GetGeoLocation.Longitude);
            bool        ZipCordsMatch  = VerifyZipCords(GetGeoLocation.ZipCode, Participantvalues.Zip);

            scoremodel = CalculateScore.CalscoreVal(CertifiedVals, mapCords, ZipCordsMatch);
            UserAgent.UserAgent ua = BrowserLookup();



            storetoDB(Participantvalues, scoremodel, GetGeoLocation, ua, mapCords);
            return(Ok());
        }
        public void TestTotalScore_PendingBonusAfterFrame1ReturnNull()
        {
            //Assemble
            List <IFrame> frames = new List <IFrame>(5);

            IFrame frame1 = new Frame()
            {
                FrameNumber = 1, BallOneIndex = 0, BallTwoIndex = 1, BonusOneEnabled = false, BonusTwoEnabled = false
            };

            frames.Add(frame1);
            IFrame frame2 = new Frame()
            {
                FrameNumber = 2, BallOneIndex = 2, BallTwoIndex = null, BonusOneEnabled = true, BonusTwoEnabled = true
            };

            frames.Add(frame2);

            balls = new List <Ball>()
            {
                new Ball {
                    PinsNockedDown = 5
                }
                , new Ball {
                    PinsNockedDown = 4
                }
                , new Ball {
                    PinsNockedDown = 10
                }
            };

            //Act
            CalculateScore calculator = new CalculateScore();
            int?           totalScore = calculator.TotalScore(frames, balls, 1);

            //Assert
            Assert.AreEqual(null, totalScore);
        }
示例#20
0
    public void DestroyObjectAndCalculatePrice()
    {
        if (exploid_action)
        {
            use_price = simple;
        }
        else
        {
            use_price = exploid;
        }
        //create bonus
        //Debug.Log (GetComponent<BonusDrop>().getStatus());
        if (GetComponent <BonusDrop>().GetStatus())
        {
            GetComponent <BonusDrop>().CreateBonus();
        }
        //Debug.Log ("DESTROY");
        //calculate price
        CalculateScore.correctPrice(use_price);

        //Destroy object
        Destroy(gameObject);
    }
        //-------------------------------------------------------------------------------------------------------------------------



        //--------------------------------------------------------------------------------------------------------------------------

        public void storetoDB(ViewModels.ParticipantViewModel Participantvalues, ScoreModel score, GeoLocProps geo, UserAgent.UserAgent useragent, MapPoint mapCoords)
        {
            ParticipantDBViewModel dbModel = CertifyParticipant.storingtoDB(Participantvalues, score, geo, useragent, mapCoords);

            Participant participant = Mapper.Map <Participant>(dbModel);


            SurveyOptionsDBModel surveymodel = CalculateScore.getthesurveyObject();

            DAL.Models.Survey surveydal = new DAL.Models.Survey();
            //defining the survey object
            surveydal.Survey_Name       = surveymodel.Survey_Name;
            surveydal.Survey_Active     = surveymodel.Survey_Active;
            surveydal.SurveyId          = surveymodel.SurveyId;
            surveydal.CalAddressScore   = surveymodel.CalAddressScore;
            surveydal.CalAgeScore       = surveymodel.CalAgeScore;
            surveydal.CalSocialScore    = surveymodel.CalSocialScore;
            surveydal.CalTwoFactorScore = surveymodel.CalTwoFactorScore;

            _unitOfWork.ParticipantRepository.InsertSurveyParticipant(participant);

            _unitOfWork.ParticipantRepository.InsertSurveyParticipantTable(participant, surveydal);
        }
        public void TestTotalScore_NoSparesAfterFrame5()
        {
            //Assemble
            List <IFrame> frames = new List <IFrame>(5);

            IFrame frame1 = new Frame()
            {
                FrameNumber = 1, BallOneIndex = 0, BallTwoIndex = 1, BonusOneEnabled = false, BonusTwoEnabled = false
            };

            frames.Add(frame1);
            IFrame frame2 = new Frame()
            {
                FrameNumber = 2, BallOneIndex = 2, BallTwoIndex = 3, BonusOneEnabled = false, BonusTwoEnabled = false
            };

            frames.Add(frame2);
            IFrame frame3 = new Frame()
            {
                FrameNumber = 3, BallOneIndex = 4, BallTwoIndex = 5, BonusOneEnabled = false, BonusTwoEnabled = false
            };

            frames.Add(frame3);
            IFrame frame4 = new Frame()
            {
                FrameNumber = 4, BallOneIndex = 6, BallTwoIndex = 7, BonusOneEnabled = false, BonusTwoEnabled = false
            };

            frames.Add(frame4);
            IFrame frame5 = new Frame()
            {
                FrameNumber = 5, BallOneIndex = 8, BallTwoIndex = 9, BonusOneEnabled = false, BonusTwoEnabled = false
            };

            frames.Add(frame5);

            balls = new List <Ball>()
            {
                new Ball {
                    PinsNockedDown = 5
                }
                , new Ball {
                    PinsNockedDown = 4
                }
                , new Ball {
                    PinsNockedDown = 3
                }
                , new Ball {
                    PinsNockedDown = 2
                }
                , new Ball {
                    PinsNockedDown = 1
                }
                , new Ball {
                    PinsNockedDown = 0
                }
                , new Ball {
                    PinsNockedDown = 1
                }
                , new Ball {
                    PinsNockedDown = 2
                }
                , new Ball {
                    PinsNockedDown = 3
                }
                , new Ball {
                    PinsNockedDown = 4
                }
            };

            //Act
            CalculateScore calculator = new CalculateScore();
            int?           totalScore = calculator.TotalScore(frames, balls, 4);

            //Assert
            Assert.AreEqual(25, totalScore);
        }
        public void TestTotalScore_AllStrikes()
        {
            //Assemble
            List <IFrame> frames = new List <IFrame>(10);

            IFrame frame1 = new Frame()
            {
                FrameNumber = 1, BallOneIndex = 0, BallTwoIndex = null, BonusOneEnabled = true, BonusTwoEnabled = true
            };

            frames.Add(frame1);
            IFrame frame2 = new Frame()
            {
                FrameNumber = 2, BallOneIndex = 1, BallTwoIndex = null, BonusOneEnabled = true, BonusTwoEnabled = true
            };

            frames.Add(frame2);
            IFrame frame3 = new Frame()
            {
                FrameNumber = 3, BallOneIndex = 2, BallTwoIndex = null, BonusOneEnabled = true, BonusTwoEnabled = true
            };

            frames.Add(frame3);
            IFrame frame4 = new Frame()
            {
                FrameNumber = 4, BallOneIndex = 3, BallTwoIndex = null, BonusOneEnabled = true, BonusTwoEnabled = true
            };

            frames.Add(frame4);
            IFrame frame5 = new Frame()
            {
                FrameNumber = 5, BallOneIndex = 4, BallTwoIndex = null, BonusOneEnabled = true, BonusTwoEnabled = true
            };

            frames.Add(frame5);
            IFrame frame6 = new Frame()
            {
                FrameNumber = 6, BallOneIndex = 5, BallTwoIndex = null, BonusOneEnabled = true, BonusTwoEnabled = true
            };

            frames.Add(frame6);
            IFrame frame7 = new Frame()
            {
                FrameNumber = 7, BallOneIndex = 6, BallTwoIndex = null, BonusOneEnabled = true, BonusTwoEnabled = true
            };

            frames.Add(frame7);
            IFrame frame8 = new Frame()
            {
                FrameNumber = 8, BallOneIndex = 7, BallTwoIndex = null, BonusOneEnabled = true, BonusTwoEnabled = true
            };

            frames.Add(frame8);
            IFrame frame9 = new Frame()
            {
                FrameNumber = 9, BallOneIndex = 8, BallTwoIndex = null, BonusOneEnabled = true, BonusTwoEnabled = true
            };

            frames.Add(frame9);
            IFrame frame10 = new Frame10()
            {
                FrameNumber = 10, BallOneIndex = 9, BallTwoIndex = 10, BallThreeEnabled = true, BallThreeIndex = 11
            };

            frames.Add(frame10);

            balls = new List <Ball>()
            {
                new Ball {
                    PinsNockedDown = 10
                }
                , new Ball {
                    PinsNockedDown = 10
                }
                , new Ball {
                    PinsNockedDown = 10
                }
                , new Ball {
                    PinsNockedDown = 10
                }
                , new Ball {
                    PinsNockedDown = 10
                }
                , new Ball {
                    PinsNockedDown = 10
                }
                , new Ball {
                    PinsNockedDown = 10
                }
                , new Ball {
                    PinsNockedDown = 10
                }
                , new Ball {
                    PinsNockedDown = 10
                }
                , new Ball {
                    PinsNockedDown = 10
                }
                , new Ball {
                    PinsNockedDown = 10
                }
                , new Ball {
                    PinsNockedDown = 10
                }
            };

            //Act
            CalculateScore calculator = new CalculateScore();
            int?           totalScore = calculator.TotalScore(frames, balls, 9);

            //Assert
            Assert.AreEqual(300, totalScore);
        }
示例#24
0
文件: Form1.cs 项目: Daoi/Scrabble
        //Dropping letter on board
        private void Button_DragDrop(object sender, DragEventArgs e)
        {
            bool   blankTile = false;
            Button btn       = (Button)sender;//The tile the letter is being placed on

            int[] index = BoardHandler.getRowCol(int.Parse(btn.Tag.ToString()));

            //Make sure an adjacent tile contains a letter or is the center piece
            if (!TilePlacement.CheckAdjacent(index[0], index[1], gameBoard))
            {
                e.Effect = DragDropEffects.None;
                return;
            }
            //Save premodified values
            boardAtTurnStart.Add(btn, btn.Text);
            handAtTurnStart.Add(currentTile, currentTile.Text);

            if (currentTile.Text == " ")
            {
                InputBox.SetLanguage(InputBox.Language.English);
                DialogResult res = InputBox.ShowDialog("Select a letter for your tile:",
                                                       "Select a letter",                                                                //Text message (mandatory), Title (optional)
                                                       InputBox.Icon.Information,                                                        //Set icon type (default info)
                                                       InputBox.Buttons.Ok,                                                              //Set buttons (default ok)
                                                       InputBox.Type.ComboBox,                                                           //Set type (default nothing)
                                                       new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
                                                                      "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }, //String field as ComboBox items (default null)
                                                       false,                                                                            //Set visible in taskbar (default false)
                                                       new System.Drawing.Font("Calibri", 10F, System.Drawing.FontStyle.Bold));          //Set font (default by system)
                currentTile.SetTileLetter(InputBox.ResultValue);
                blankTile = true;
            }

            //If it's a preimum board tile, record the multiplier
            if (btn.Text.Equals("Double Word Score") || btn.Text.Equals("*"))
            {
                scoreMultiplier *= 2;
            }
            else if (btn.Text.Equals("Triple Word Score"))
            {
                scoreMultiplier *= 3;
            }
            //Calculate value for premium tiles
            score += CalculateScore.CaluclatePlacedTileScore(btn, currentTile);
            tilesThisTurn.Add(currentTile.Text);

            //Potentially useless
            currentTile.SetBoardPosition(int.Parse(btn.Tag.ToString()));
            //Update board tile
            ib.addTile(new LetterTile(currentTile.Text, currentTile.GetBoardPosition()));

            if (blankTile)
            {
                btn.Text = currentTile.Text;
            }
            else
            {
                btn.Text = e.Data.GetData(DataFormats.StringFormat).ToString();
            }

            btn.AllowDrop = false;
            placements.Add(int.Parse(btn.Tag.ToString()));
            currentTile.Text = "";
        }
示例#25
0
 // Use this for initialization
 void Start()
 {
     m                 = FindObjectOfType <MusicManager>();
     calscore          = FindObjectOfType <CalculateScore>();
     totalMonster.text = calscore.score.ToString();
 }
示例#26
0
 void Start()
 {
     singleton = this;
 }
示例#27
0
        public void TestBowling_Mix()
        {
            //Assemble
            HardcodedPinPhysics physics = new HardcodedPinPhysics(balls_Mix);
            GoBowling           bowl    = new GoBowling(physics);

            //Act
            int pinsNockedDown01 = bowl.ThrowBall(1);
            int pinsNockedDown02 = bowl.ThrowBall(2);
            int pinsNockedDown03 = bowl.ThrowBall(1);
            int pinsNockedDown04 = bowl.ThrowBall(2);
            int pinsNockedDown05 = bowl.ThrowBall(1);
            int pinsNockedDown06 = bowl.ThrowBall(1);
            int pinsNockedDown07 = bowl.ThrowBall(2);
            int pinsNockedDown08 = bowl.ThrowBall(1);
            int pinsNockedDown09 = bowl.ThrowBall(2);
            int pinsNockedDown10 = bowl.ThrowBall(1);
            int pinsNockedDown11 = bowl.ThrowBall(2);
            int pinsNockedDown12 = bowl.ThrowBall(1);
            int pinsNockedDown13 = bowl.ThrowBall(2);
            int pinsNockedDown14 = bowl.ThrowBall(1);
            int pinsNockedDown15 = bowl.ThrowBall(2);
            int pinsNockedDown16 = bowl.ThrowBall(1);
            int pinsNockedDown17 = bowl.ThrowBall(2);
            int pinsNockedDown18 = bowl.ThrowBall(1);
            int pinsNockedDown19 = bowl.ThrowBall(2);
            int pinsNockedDown20 = bowl.ThrowBall(3);

            //Assert
            Assert.AreEqual(5, pinsNockedDown01);
            Assert.AreEqual(5, pinsNockedDown02);
            Assert.AreEqual(6, pinsNockedDown03);
            Assert.AreEqual(3, pinsNockedDown04);
            Assert.AreEqual(10, pinsNockedDown05);
            Assert.AreEqual(7, pinsNockedDown06);
            Assert.AreEqual(2, pinsNockedDown07);
            Assert.AreEqual(8, pinsNockedDown08);
            Assert.AreEqual(2, pinsNockedDown09);
            Assert.AreEqual(5, pinsNockedDown10);
            Assert.AreEqual(5, pinsNockedDown11);
            Assert.AreEqual(0, pinsNockedDown12);
            Assert.AreEqual(6, pinsNockedDown13);
            Assert.AreEqual(0, pinsNockedDown14);
            Assert.AreEqual(7, pinsNockedDown15);
            Assert.AreEqual(2, pinsNockedDown16);
            Assert.AreEqual(2, pinsNockedDown17);
            Assert.AreEqual(10, pinsNockedDown18);
            Assert.AreEqual(4, pinsNockedDown19);
            Assert.AreEqual(4, pinsNockedDown20);

            CalculateScore calculate  = new CalculateScore();
            int?           totalScore = calculate.TotalScore(bowl.Frames, bowl.Balls, 9);

            Assert.AreEqual(113, totalScore.Value);

            totalScore = calculate.TotalScore(bowl.Frames, bowl.Balls, 5);
            Assert.AreEqual(78, totalScore.Value);

            totalScore = calculate.TotalScore(bowl.Frames, bowl.Balls, 0);
            Assert.AreEqual(16, totalScore.Value);
        }
示例#28
0
 public void Should_return_25_points_for_15_correct_guesses()
 {
     CalculateScore.Calculate(15).Should().Be(25);
 }
示例#29
0
 public void Should_return_5_points_for_3_correct_guesses()
 {
     CalculateScore.Calculate(3).Should().Be(5);
 }
示例#30
0
 public void Should_return_N_points_for_N_correct_less_than_three()
 {
     CalculateScore.Calculate(1).Should().Be(1);
     CalculateScore.Calculate(2).Should().Be(2);
 }