Created
April 11, 2012 14:39
-
-
Save mazur/2359726 to your computer and use it in GitHub Desktop.
Steal Underpants Enumerator
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
namespace StealTheseUnderpants | |
{ | |
using System; | |
public class Underpants | |
{ | |
public UnderpantsEnumerator GetEnumerator() | |
{ | |
return new UnderpantsEnumerator(); | |
} | |
} | |
public class UnderpantsEnumerator | |
{ | |
private int stolen = 0; | |
public void Reset() | |
{ | |
stolen = 0; | |
} | |
public object Current | |
{ | |
get { return "Stolen underpants!"; } | |
} | |
public bool MoveNext() | |
{ | |
return stolen++ < 3; | |
} | |
} | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
foreach (var s in new Underpants()) | |
{ | |
Console.WriteLine(s); | |
} | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment