Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyDiner{
- private string[] _menuitems;
- private int _position;
- private IEnumerable<string> _subMenu;
- public MyDiner(ICollection<string> subMenu) : IEnumerable{
- _position = 0;
- _menuItems = new string[] {"Coffee", "Latte machiato", "Cappuchino"};
- _submenu = submenu.Iterator();
- }
- public bool HasNext(){
- return _submenu.HasNext();
- }
- public string Next(){
- if(_position < _menuitems.length){
- _position ++;
- return = __menuItems[_position - 1];
- }
- else if(_submenu.HasNext()){
- return _submenu.Next();
- }
- else {
- thow new IllegalOperationException("I'm out of elements!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement