Example #1
0
        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));
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
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();
        }