forked from MohammadSianaki/Design-Pattern-In-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIteratorPatternDemo.java
More file actions
31 lines (29 loc) · 1.38 KB
/
Copy pathIteratorPatternDemo.java
File metadata and controls
31 lines (29 loc) · 1.38 KB
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
class IteratorPatternDemo {
public static void main(String[] args) {
ChannelCollection channels = populateChannels();
ChannelIterator baseIterator = channels.iterator(ChannelType.ALL);
while (baseIterator.hasNext()) {
Channel c = baseIterator.next();
System.out.println(c.toString());
}
System.out.println("*****************");
ChannelIterator englishIterator = channels.iterator(ChannelType.ENGLISH);
while (englishIterator.hasNext()) {
Channel c = englishIterator.next();
System.out.println(c.toString());
}
}
private static ChannelCollection populateChannels() {
ChannelCollection channels = new ChannelCollectionImpl();
channels.addChannel(new Channel(98.5, ChannelType.ENGLISH));
channels.addChannel(new Channel(99.5, ChannelType.HINDI));
channels.addChannel(new Channel(100.5, ChannelType.FRENCH));
channels.addChannel(new Channel(101.5, ChannelType.ENGLISH));
channels.addChannel(new Channel(102.5, ChannelType.HINDI));
channels.addChannel(new Channel(103.5, ChannelType.FRENCH));
channels.addChannel(new Channel(104.5, ChannelType.ENGLISH));
channels.addChannel(new Channel(105.5, ChannelType.HINDI));
channels.addChannel(new Channel(106.5, ChannelType.FRENCH));
return channels;
}
}