import java.io.*;

public class StringSCL {
	private Nodo nodoinit;
    public StringSCL () {
		nodoinit = null;
	}
	public StringSCL (Nodo n) {
		nodoinit = n;
	}
    public boolean empty () {
		return (nodoinit==null);
	}
	public void addElement (String o) throws SCLeccezione {
		Nodo aux = new Nodo();
		aux.setInfo(o);
		aux.setNext(this.nodoinit);
		nodoinit=aux;
	}
	public String getFirstElement () throws SCLeccezione {
		if (this.empty())
			throw new SCLeccezione("errore-getFirstElement");
		else return (String) nodoinit.getInfo();		
	}
	public void print () throws SCLeccezione {
    	if (!this.empty()) {
		  Nodo aux=this.nodoinit;
		  while (aux != null) {
		  	System.out.println(aux.getInfo());
          	aux=aux.getNext();
		  }
      }
	}
   public static StringSCL readbSCL (BufferedReader br) throws SCLeccezione, IOException {
    StringSCL aux = new StringSCL ();
    String o = br.readLine();
    while (o != null){
      aux.addElement(o);
      o = br.readLine();
    }
    return aux;
  }
  

  public static StringSCL readfSCL (BufferedReader br) throws SCLeccezione, IOException {
    String o = br.readLine();
    if (o == null) 
      return new StringSCL();
    else {
      StringSCL s = readfSCL(br);
      s.addElement(o);
      return s;
    }
  }
  

  public static void main(String[] args) throws IOException, SCLeccezione {
          FileInputStream filein =
            new FileInputStream (new File ("testSCL.txt"));
          BufferedReader br =
            new BufferedReader(new InputStreamReader(filein));

          StringSCL l1 = readfSCL(br);
	  l1.print();

//	  System.out.println(l1.countElements("Anna"));

//        StringSCL l2 = l1.copia();
//	  l2.print();

//	  l1.insertBefore("Anna","Daniele");
//	  l1.stampaSCL();

//	  l1.removeElement(30);
//	  l1.stampaSCL();

//	  l1.removeElement(2);
//	  l1.print();

//	  l1.remove("Anna");
//	  l1.print();

//	  l1.remove("pippo");
//	  l1.print();
	}
}

