Skip to content

Instantly share code, notes, and snippets.

Created August 7, 2014 20:27
Show Gist options
  • Save anonymous/4a12b59b4d87c0aae4fe to your computer and use it in GitHub Desktop.
Save anonymous/4a12b59b4d87c0aae4fe to your computer and use it in GitHub Desktop.
A Day at the Races
public 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
int moveForward = Randomizer.Next(1, 4);
//Update the position of the picture box on the form
MyPictureBox.Left = StartingPosition + Location;
// Return true if I won the race
}
public void TakeStartingPosition()
{
// Reset my location to 0 and my PictureBox to starting position
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment