コード例 #1
0
 @Override
 public Object Next() {
   Object rect = null;
   current++;
   if (current < aggregate.count()) {
     rect = aggregate.get(current);
   }
   return rect;
 }
コード例 #2
0
  public static void main(String[] args) {

    ConcreteAggregate aggregate = new ConcreteAggregate();
    aggregate.set(0, "哈哈0");
    aggregate.set(1, "哈哈1");
    aggregate.set(2, "哈哈2");
    aggregate.set(3, "哈哈3");
    aggregate.set(4, "哈哈4");
    aggregate.set(5, "哈哈5");

    Iterator i = new ConcreteIterator(aggregate);

    Object item = i.First();
    while (!i.IsDone()) {
      System.out.println(i.CurrentItem() + "请买票");
      i.Next();
    }
  }
コード例 #3
0
 @Override
 public Object CurrentItem() {
   return aggregate.get(current);
 }
コード例 #4
0
 @Override
 public boolean IsDone() {
   return current >= aggregate.count() ? true : false;
 }
コード例 #5
0
 @Override
 public Object First() {
   return aggregate.get(0);
 }