/// <summary> /// Make a Racer given a horizontal position and how far to move. /// </summary> /// <param name="tracknumber">track number (starts at 0)</param> /// <param name="xPos">initial horizontal position on track</param> /// <param name="distanceToTravel">how far to move in track until reaching next Racer or finish</param> public Racer(RaceTrack rt, int tracknumber, int xPos, int distanceToTravel) { this.raceTrack = rt; this.track = tracknumber; this.xPos = xPos; this.distance = distanceToTravel; rgen = new Random(); this.sleep = rgen.Next(MINSLEEP, MAXSLEEP); this.speed = rgen.Next(MINSPEED, MAXSPEED); this.endPoint = xPos + speed; Thread.Sleep(TIMEBUFFER); } // constructor Racer
/// <summary> /// Make a Racer given a horizontal position and how far to move. /// </summary> /// <param name="tracknumber">track number (starts at 0)</param> /// <param name="xPos">initial horizontal position on track</param> /// <param name="distanceToTravel">how far to move in track until reaching next Racer or finish</param> public Racer(RaceTrack rt, int tracknumber, int xPos, int distanceToTravel) { raceTrack = rt; track = tracknumber; this.xPos = xPos; distance = distanceToTravel; //Generate random speeds for the racers by using a timebuffer bewteen random object instantiation Thread.Sleep(TIMEBUFFER); rgen = new Random(); sleep = rgen.Next(MINSLEEP, MAXSLEEP); speed = rgen.Next(MINSPEED, MAXSPEED); //Calculate the endpoint for this racer endPoint = xPos + distance; } // constructor Racer
/// <summary> /// Make a Racer given a horizontal position and how far to move. /// </summary> /// <param name="tracknumber">track number (starts at 0)</param> /// <param name="xPos">initial horizontal position on track</param> /// <param name="distanceToTravel">how far to move in track until reaching next Racer or finish</param> public Racer(RaceTrack rt, int tracknumber, int xPos, int distanceToTravel) { //Parameter instantiation raceTrack = rt; track = tracknumber; this.xPos = xPos; distance = distanceToTravel; //Random object with timebuffer to change the random seed rng = new Random(); Thread.Sleep(TIMEBUFFER); //Random time step and distance traveled sleep = rng.Next(MINSLEEP, MAXSLEEP); speed = rng.Next(MINSPEED, MAXSPEED); //Endpoint for the racer endPoint = this.xPos + distance; } // constructor Racer
/// <summary> /// Make a Racer given a horizontal position and how far to move. /// </summary> /// <param name="tracknumber">track number (starts at 0)</param> /// <param name="xPos">initial horizontal position on track</param> /// <param name="distanceToTravel">how far to move in track until reaching next Racer or finish</param> public Racer(RaceTrack rt, int tracknumber, int xPos, int distanceToTravel) { // to complete! } // constructor Racer