⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kidclub.java

📁 正在学习Java的人或许能从中得到自己想要的东西
💻 JAVA
字号:
import java.util.*;

public class kidClub
implements Iterator {
    private String clubMask;     //name of club
    private Kid kid;             //next kid to return
    private Iterator ke;      //gets all kids
    private KidData kdata;       //class containing kids
//----------------------------------------
    public kidClub(KidData kd, String club) {
        clubMask = club;     //save the club
        kdata = kd;          //copy the class
        kid = null;          //default
        ke = kdata.iterator();  //get Enumerator
    }
//----------------------------------------
    public boolean hasNext() {
        //return true if there are any more kids 
        //belonging to the specified club
        boolean found = false;
        while (ke.hasNext() && ! found) {
            kid = (Kid)ke.next();
            found = kid.getClub().equals(clubMask);
        }
        if (! found)
            kid = null;    //set to null if none left
        return found;
    }
//----------------------------------------
    public Object next() {
        if (kid != null)
            return kid;
        else
            //throw exception if access past end
            throw new NoSuchElementException();
    }
    public void remove() {
        //do nothing
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -