This repository has been archived on 2022-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
patterns/iterator/simpleiterator/dinermenuiterator.d

25 lines
383 B
D

module dinermenuiterator;
import iterator, menuitem;
class DinerMenuIterator : Iterator
{
private MenuItem[] items;
private int position;
this(MenuItem[] items)
{
this.items = items;
}
override MenuItem next()
{
return items[position++];
}
override bool hasNext()
{
return items.length > position;
}
}