-
Notifications
You must be signed in to change notification settings - Fork 252
/
Copy pathProgram.cs
39 lines (34 loc) · 1.22 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Iterator
{
class Program
{
static void Main(string[] args)
{
// Build a collection of jelly beans
JellyBeanCollection collection = new JellyBeanCollection();
collection[0] = new JellyBean("Cherry");
collection[1] = new JellyBean("Bubble Gum");
collection[2] = new JellyBean("Root Beer");
collection[3] = new JellyBean("French Vanilla");
collection[4] = new JellyBean("Licorice");
collection[5] = new JellyBean("Buttered Popcorn");
collection[6] = new JellyBean("Juicy Pear");
collection[7] = new JellyBean("Cinnamon");
collection[8] = new JellyBean("Coconut");
// Create iterator
JellyBeanIterator iterator = collection.CreateIterator();
Console.WriteLine("Gimme all the jelly beans!");
for (JellyBean item = iterator.First();
!iterator.IsDone; item = iterator.Next())
{
Console.WriteLine(item.Flavor);
}
Console.ReadKey();
}
}
}