Ejemplo n.º 1
0
        private void GetAttempts()
        {
            var att      = AttemptsControl.Get(Type);
            var attempts = att.Where(x => x.IdQuestion == Id);

            foreach (var item in attempts)
            {
                Tries.Add(new DateTry(item.Score, item.When));
            }
        }
Ejemplo n.º 2
0
        public void Should_return_number_of_words_when_find_for_prefix()
        {
            var input   = new[] { "CAR", "CARD", "CARDAN", "TRY", "TRIES", "TRIED" };
            var printer = new FakePrinter("{0:#}");
            var tries   = new Tries();

            foreach (var s in input)
            {
                tries.Add(s);
            }

            var cCount = tries.Find("C");

            Assert.Equal(3, cCount);
            var carCount = tries.Find("CAR");

            Assert.Equal(3, carCount);
            var cardCount = tries.Find("CARD");

            Assert.Equal(2, cardCount);
            var cardanCount = tries.Find("CARDAN");

            Assert.Equal(1, cardanCount);

            var tCount = tries.Find("T");

            Assert.Equal(3, tCount);
            var trCount = tries.Find("TR");

            Assert.Equal(3, trCount);
            var tryCount = tries.Find("TRY");

            Assert.Equal(1, tryCount);
            var trieCount = tries.Find("TRIE");

            Assert.Equal(2, trieCount);
            var triesCount = tries.Find("TRIES");

            Assert.Equal(1, triesCount);
            var triedCount = tries.Find("TRIED");

            Assert.Equal(1, triedCount);

            var nCount = tries.Find("N");

            Assert.Equal(0, nCount);

            tries.Print(printer);

            foreach (var s in input)
            {
                Assert.Contains(s, printer.Printed);
            }
            Assert.Equal(6, printer.Printed.Count);
        }
Ejemplo n.º 3
0
        public void Should_construct_a_valid_tries_when_adding_strings()
        {
            var input   = new[] { "CAR", "CARD", "CARDAN" };
            var printer = new FakePrinter("{0:#}");
            var tries   = new Tries();

            foreach (var s in input)
            {
                tries.Add(s);
            }
            tries.Print(printer);
            Assert.Equal("CAR", printer.Printed[0]);
            Assert.Equal("CARD", printer.Printed[1]);
            Assert.Equal("CARDAN", printer.Printed[2]);

            Assert.Equal(3, printer.Printed.Count);
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> GetTrieAsync()
        {
            var client  = new Client();
            var players = await client.GetAll();

            Tries t = new Tries();

            t.CreateRoot();
            foreach (var player in players)
            {
                var fullName = player.player.FirstName + player.player.LastName;
                t.Add(fullName.ToCharArray(), player);
            }


            var player1 = t.FindPlayer("LebronJames".ToCharArray());

            return(View(player1.player));
        }
Ejemplo n.º 5
0
        public void TreatTransaction(string rawTransaction)
        {
            var parts       = rawTransaction.Split(' ');
            var transaction = (TransactionType)Enum.Parse(typeof(TransactionType), parts[0], true);
            var word        = parts[1];

            switch (transaction)
            {
            case TransactionType.Add:
                _contacts.Add(word);
                break;

            case TransactionType.Find:
                _printer.Print(_contacts.Find(word));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 6
0
        public EnigmaGuessResult GuessColors(EnigmaColor[] colors)
        {
            CheckRunningGame();
            var guessResult = new EnigmaGuessResult();

            if (colors == null || colors.Length != enigmaFields.Length)
            {
                throw new ArgumentException($"Input must be of size {enigmaFields.Length}");
            }

            for (var i = 0; i < enigmaFields.Length; i++)
            {
                guessResult.tries[i] = new EnigmaField(colors[i], enigmaFields[i].Guess(colors[i]));
            }

            Tries.Add(guessResult);

            if (AllColorsGuessed())
            {
                IsRunning = false;
                IsWon     = true;
            }
            else
            {
                CurrentNumberOfTries -= 1;

                if (CurrentNumberOfTries >= 1)
                {
                    return(guessResult);
                }
                IsRunning = false;
                IsWon     = false;
            }

            return(guessResult);
        }