Created
May 30, 2021 13:23
-
-
Save ssukhpinder/cd742cc7861c7860a1999178146293c9 to your computer and use it in GitHub Desktop.
This file contains 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 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