Skip to content

Instantly share code, notes, and snippets.

@ssukhpinder
Created May 30, 2021 13:23
Show Gist options
  • Save ssukhpinder/cd742cc7861c7860a1999178146293c9 to your computer and use it in GitHub Desktop.
Save ssukhpinder/cd742cc7861c7860a1999178146293c9 to your computer and use it in GitHub Desktop.
public class CarIterator : IVehicleIterator
{
private List<string> _cars;
private int _current;
public CarIterator(List<string> cars)
{
_cars = cars;
_current = 0;
}
public string Current()
{
return _cars.ElementAt(_current);
}
public void First()
{
_current = 0;
}
public bool IsDone()
{
return _current >= _cars.Count;
}
public string Next()
{
return _cars.ElementAt(_current++);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment