示例#1
0
        public void TestEliminaSuspeito()
        {
            LinUstOrvalds l = new LinUstOrvalds(5, 5, 5);

            Dictionary<string, int> guess = l.nextGuess(1);

            Assert.AreEqual(guess[Constants.KEY_SUSPECT], 1);
            Assert.AreEqual(guess[Constants.KEY_PLACE], 0);
            Assert.AreEqual(guess[Constants.KEY_GUN], 0);
        }
示例#2
0
        public void btnSolucionar_Click(Object sender,
            EventArgs e)
        {
            //Initialize the witness
            Witness witness = new Witness(lbSuspects.SelectedIndex,
                                                   lbPlaces.SelectedIndex,
                                                   lbGuns.SelectedIndex);

            //Ititialize the detective
            LinUstOrvalds detective = new LinUstOrvalds(lbSuspects.Items.Count,
                                                        lbGuns.Items.Count,
                                                        lbPlaces.Items.Count);

            int nextTip = 0;
            Dictionary<string, int> guess = null;
            StringBuilder sb = new StringBuilder();
            int counter = 1;
            string solution = "";
            do
            {
                guess = detective.nextGuess(nextTip);

                nextTip = witness.nextTip(guess);
                switch (nextTip)
                {
                    case 1:
                        sb.Append(string.Format("<strong>#{0}: Lin Ust Orvalds:</strong> {1} <br>", counter, printCurrentGuess(guess)));
                        counter++;
                        sb.Append(string.Format("<strong>#{0}: Testemunha:</strong> Não, não foi este cara. <br>", counter));
                        break;
                    case 2:
                        sb.Append(string.Format("<strong>#{0}: Lin Ust Orvalds:</strong> {1} <br>", counter, printCurrentGuess(guess)));
                        counter++;
                        sb.Append(string.Format("<strong>#{0}: Testemunha:</strong> O lugar está errado. <br>", counter));
                        break;
                    case 3:
                        sb.Append(string.Format("<strong>#{0}: Lin Ust Orvalds:</strong> {1} <br>", counter, printCurrentGuess(guess)));
                        counter++;
                        sb.Append(string.Format("<strong>#{0}: Testemunha:</strong> Foi outro arma. <br>", counter));
                        break;
                    default:
                        sb.Append(string.Format("<strong>#{0}: Lin Ust Orvalds:</strong> {1} <br>", counter, printCurrentGuess(guess)));
                        counter++;
                        sb.Append(string.Format("<strong>#{0}: Testemunha:</strong> Isso! <br>", counter));
                        solution = printCurrentGuess(guess);
                        break;
                }
                counter++;
            } while (nextTip != 0);

            result.Text = string.Format(RESULT, solution, sb.ToString());
            upResults.Update();
        }