package com.yanjinbin.designPattern.迭代器模式;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 颜巾斌
 *         Created on 六月 30. tag:windows
 */

public class ConcreteIterator implements Iterator {
    private List list = new ArrayList();
    private int cursor = 0 ;
    public ConcreteIterator(List list){
        this.list = list;
    }
    public Object next() {
        Object object = null;
        if(this.hasNext()){
            object = this.list.get(cursor++);
        }
        return object;
    }

    public boolean hasNext() {
        if(cursor==list.size()){
            return false;
        }
        else return true;

    }
}
