-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOutPutImpl.java
More file actions
35 lines (27 loc) · 822 Bytes
/
OutPutImpl.java
File metadata and controls
35 lines (27 loc) · 822 Bytes
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
package Gof.iterator;
import java.util.List;
import java.util.Iterator;
public class OutPutImpl {
List<College> collegeList;
public OutPutImpl(List<College> collegeList) {
this.collegeList = collegeList;
}
//遍历整个学校
public void printCollege()
{
Iterator<College> iterator = collegeList.iterator();
while(iterator.hasNext())
{
College college=iterator.next();
System.out.println("======"+college.getName()+"========");
printDepartment(college.createIterator());
}
}
public void printDepartment(Gof.iterator.Iterator iterator){
while(iterator.hasNext())
{
Department next = (Department)iterator.next();
System.out.println(next.getName());
}
}
}