// Method to randomize the animalIndex order private void RandomizeAnimals() { Random randomizer = new Random(); for (int i = 0; i < animals.getSize(); i++) { int newIndex = randomizer.Next(animals.getSize()); int buffer = animalIndexes[i]; animalIndexes[i] = animalIndexes[newIndex]; animalIndexes[newIndex] = buffer; } }
// 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 }
public LearningPage() { Animals animals = new Animals(); InitializeComponent(); for (int i = 0; i < animals.getSize(); i++) { PivotItem pivotItem = new PivotItem(); Image image = new Image(); image.Source = new BitmapImage(animals.getAnimalIndex(i).getAnimalImage()); pivotItem.Header = animals.getAnimalIndex(i).getAnimalName(); pivotItem.Content = image; AnimalLearningPivot.Items.Add(pivotItem); } //on animal selection take them to a seperate scene with animal name, animal facts, and animal sounds. //need to research animal facts and add them to xml files //create image view with each animal in it //add event when animal is clicked update thread // }
BitmapImage chosenAnimal; //animal chosen to display //*************************************************************************************************** //chooses a random animal from the model, creates random positions and places images randomely void generateImagePlacement() { animalPath = animals.getAnimalIndex(AnimalMath.random.Next(animals.getSize())).getAnimalImage(); chosenAnimal = new BitmapImage(animalPath); //holds new image to be placed AnimalMath.GenerateRandomArrays(); //reset random generation for new unique numbers int position; //position for animal to be placed in for (int k = 0; k < AnimalMath.correctAnswer; k++) { position = AnimalMath.getRandomNum(); //get new unique random integer placeImage(position, chosenAnimal); //call function to place images within grid } }
public LearningPage() { Animals animals = new Animals(); InitializeComponent(); for (int i = 0; i < animals.getSize(); i++) { PivotItem pivotItem = new PivotItem(); Image image = new Image(); image.Source = new BitmapImage(animals.getAnimalIndex(i).getAnimalImage()); pivotItem.Header = animals.getAnimalIndex(i).getAnimalName(); pivotItem.Content = image; AnimalLearningPivot.Items.Add(pivotItem); } }
void generateImagePlacement() { animalPath = animals.getAnimalIndex(random.Next(animals.getSize())).getAnimalImage(); chosenAnimal = new BitmapImage(animalPath); for (int i = 0; i < MAX_NUMBER; i++) { num_array[i] = i + 1; // initialise them to their indexes } //csize = MAX_CHOICES; // nsize = MAX_NUMBER; //used for array size in random # selection int position; // for (int k = 0; k < correctAnswer; k++) { //if ((position = getRandomNum()) != 0) //{ position = getRandomNum(); //position = 3; placeImage(position, chosenAnimal); //} } }
private void button1_Click(object sender, RoutedEventArgs e) { //<<<<<<< .mine //This is just test code, making sure that AnimalStructure works imageBox.Source = new BitmapImage(animals.getAnimalIndex(imageIndex++).getAnimalImage()); if (imageIndex == animals.getSize()) { imageIndex = 0; } /* * For each index in animals.getsize * create new pivot page * each pivot has an image of the animal * and makes the animal's sound when selected * * on select the pivot is not iterrupted but keeps * * */ //======= // check the name of the button switch (button1.Content.ToString()) { case "Check": // if the button says Check, display the results and set the button to Next // or Main Page if all animals have been cycled string input = textBox1.Text; string answer = animals.getAnimalIndex(imageIndex).getAnimalName(); displayResults(input, answer); if (++imageIndex == animals.getSize()) { button1.Content = "Main Page"; } else { button1.Content = "Next"; } break; case "Next": // if the button says Next, reset all controls and go to next animal textBox1.Text = ""; textBlock1.Text = ""; button1.Content = "Check"; button1.IsEnabled = false; imageBox.Source = new BitmapImage(animals.getAnimalIndex(imageIndex).getAnimalImage()); break; case "Main Page": // if the button says Main Page, navigate to the main page this.NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); break; } ////This is just test code, making sure that AnimalStructure works //imageBox.Source = new BitmapImage(animals.getAnimalIndex(imageIndex++).getAnimalImage()); //if (imageIndex == animals.getSize()) // imageIndex = 0; //>>>>>>> .r27 }
// 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 }