How to add random with an int
I am doing this lab from Head First C# book
there's 4 dogs and 3 dudes who can bet on those dogs.
dogs will move at random so i have to use random generator.
My question is how do I update the form through the Run() method?
======================Book==========================
class Greyhound {
public int StartingPosition; // Where my PictureBox starts
public int RacetrackLength; // How long the racetrack is
public PictureBox MyPictureBox = null; // My PictureBox object
public int Location = 0; // My Location on the racetrack
public Random Randomizer; // An instance of Random
public bool Run() {
// Move forward either 1, 2, 3 or 4 spaces at random
// Update the position of my PictureBox on the form
// Return true if I won the race
}
public void TakeStartingPosition() {
// Reset my location to the start line
============My Work=========================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TheRace
{
class Greyhound
{
public int StartingPosition;
public int RacetrackLength;
public PictureBox MyPictureBox = null;
public int Location = 0;
public Random Randomizer = new Random();
public bool Run()
{
Location = StartingPosition + Randomizer.Next(1,4);
}
public void TakeStartingPoisition()
{
}
}