- 
      
 - 
        
Save anonymous/4a12b59b4d87c0aae4fe to your computer and use it in GitHub Desktop.  
    A Day at the Races
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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