コード例 #1
0
ファイル: WitnessTests.cs プロジェクト: rovianvz/Detetive
        public void TesteRetornoSuspeitoEArmaErrado()
        {
            Witness t = new Witness(3, 3, 3);

            Dictionary<string, int> hint = new Dictionary<string, int>();
            hint.Add(Constants.KEY_SUSPECT, 4);
            hint.Add(Constants.KEY_PLACE, 3);
            hint.Add(Constants.KEY_GUN, 4);

            Assert.IsTrue((t.nextTip(hint) == 1) || (t.nextTip(hint) == 3));
        }
コード例 #2
0
ファイル: WitnessTests.cs プロジェクト: rovianvz/Detetive
        public void TesteRetornoRespostaCorreta()
        {
            Witness t = new Witness(3, 3, 3);

            Dictionary<string, int> hint = new Dictionary<string, int>();
            hint.Add(Constants.KEY_SUSPECT, 3);
            hint.Add(Constants.KEY_PLACE, 3);
            hint.Add(Constants.KEY_GUN, 3);

            Assert.AreEqual(t.nextTip(hint), 0);
        }
コード例 #3
0
ファイル: WitnessTests.cs プロジェクト: rovianvz/Detetive
        public void TesteRetornoSomenteSuspeitoErrado()
        {
            Witness t = new Witness(3, 3, 3);

            Dictionary<string, int> hint = new Dictionary<string, int>();
            hint.Add(Constants.KEY_SUSPECT, 4);
            hint.Add(Constants.KEY_PLACE, 3);
            hint.Add(Constants.KEY_GUN, 3);

            Assert.AreEqual(t.nextTip(hint), 1);
        }
コード例 #4
0
ファイル: Default.aspx.cs プロジェクト: rovianvz/Detetive
        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();
        }