Esempio n. 1
0
 // Initializes fields and properties, randomizes the animals list, and sets the
 // currentIndex to the first random animal index
 public void Initialize()
 {
     animals       = new Animals();
     animalIndexes = new int[animals.getSize()];     // initialize list of indexes
     for (int i = 0; i < animals.getSize(); i++)
     {
         animalIndexes[i] = i;
     }
     RandomizeAnimals();                             // randomize index order
     currentIndex = 0;                               // index of current animal
     animals.setUsed(animalIndexes[currentIndex]);   // set the first animal as used
     results.Clear();                                // clear the previous results
 }
Esempio n. 2
0
        // Sets the next animal based on a random animal index. No animal in the animal set
        // is reapeted. Once the set of remaining animals is empty, sets the current animal
        // to null.
        public Animal NextAnimal(String input)
        {
            VerifiedLetterCollection verifiedInput = VerifyInput(input, GetCurrentAnimal().getAnimalName());

            // add the current input to results
            results.AddResult(GetCurrentAnimal(), verifiedInput);

            if (allAnimalsUsed)
            {
                currentIndex = -1;
            }

            if (currentIndex > -1 && currentIndex < animals.getSize())
            {
                // set the current animal used
                animals.setUsed(animalIndexes[++currentIndex]);
            }

            return(GetCurrentAnimal());
        }
Esempio n. 3
0
 // Initializes fields and properties, randomizes the animals list, and sets the
 // currentIndex to the first random animal index
 public void Initialize()
 {
     animals = new Animals();
     animalIndexes = new int[animals.getSize()];     // initialize list of indexes
     for (int i = 0; i < animals.getSize(); i++)
         animalIndexes[i] = i;
     RandomizeAnimals();                             // randomize index order
     currentIndex = 0;                               // index of current animal
     animals.setUsed(animalIndexes[currentIndex]);   // set the first animal as used
     results.Clear();                                // clear the previous results
 }