import java.io.IOException;

class Element{
    int inhalt;
    Element(int i){ inhalt = i;}
}

class ElementListe{
    Element e;
    ElementListe next;
    ElementListe(ElementListe el, Element eneu){ e = eneu; next = el;}
}

interface Behaelter{
    boolean istLeer();
    Element nimmEines();
}

class MyRandom{
    static java.util.Random RGen = new java.util.Random();
	
	static Element random(int max){
	    int i = Math.abs(RGen.nextInt());
	    return new Element(i % max);
	    }
}    

class Container implements Behaelter{
    // Verwaltet Elemente - mindestens eines
    ElementListe el;
    Container(int n){
        for (int k = 0; k < 42; k++) el = new ElementListe(el, MyRandom.random(2*n));
        }
    public Element nimmEines(){
        if (el == null) return null;
        Element x = el.e;
        el = el.next;
        return x;
        }
    public boolean istLeer() { return el == null; }
}


class LinSuche {
    
    boolean p(Element e){return e.inhalt == 42;}
    

    Container cont = new Container(42);
    Element linSuche(){
        while( !cont.istLeer() ){
            Element e = cont.nimmEines();
            if (p(e)) return e;
            }
        return null;
        }
}

public class LinSuche1 {

    public static void main(String args[]) {
        System.out.println("Lineare Suche 1");
        System.out.println("");
        for (int i = 0; i<10; i++){
            LinSuche L = new LinSuche();
            Element e = L.linSuche();
            if (e != null) System.out.println("Gefunden !");
            else System.out.println("Nicht gefunden !");
            }
  
    }
}
