public void walk() { Random random = new Random(); int ranNum = random.Next(0, 2); RandomEventDelegate RE = new RandomEventDelegate(this, ranNum); if (moveEvent != null) { moveEvent(RE); } else { hasNext = false; } }
public void walk(RandomEventDelegate r) { TotalStep++; if (r.Direction == 0) { dir = "Right"; Pos++; } else { Pos--; dir = "Left"; } if (Pos == Max || Pos == Min) { Console.WriteLine("Total step to move {0} spaces to the {1} is: {2}", Math.Abs(Pos), dir, TotalStep); r.Walker.moveEvent -= walk; } }