import java.io.*;

public class TestSCLFun {

    public static SCLFun leggiSCLFun (BufferedReader br) 
	                         throws SCLeccezione, IOException {
	SCLFun aux = new SCLFun ();
	String o = br.readLine();
	while (o != null){
	    aux.addElement(o);
	    o = br.readLine();
	}
	return aux;
    }

    public static SCLFun leggiavantiSCLFun (BufferedReader br) 
	                        throws SCLeccezione, IOException {
	String o = br.readLine();
	if (o == null) 
	    return new SCLFun ();
	else return leggiavantiSCLFun(br).addElement(o);
    }

    public static void main(String[] args) throws IOException, SCLeccezione {
	
	FileInputStream filein =
	    new FileInputStream (new File ("testSCL.txt"));
	BufferedReader br =
	    new BufferedReader(new InputStreamReader(filein));

	SCLFun l1 = leggiavantiSCLFun(br);
	System.out.println("\nLista letta da file");
	System.out.print("l1 = ");
	l1.printSCL();

	System.out.println("\nInserisco X in posizione 5");
	SCLFun l2 = l1.insertElementAt(5,"X");
	System.out.print("l1 = ");
	l1.printSCL();
	System.out.print("l2 = ");
	l2.printSCL();
	
	System.out.println("\nRimuovo gli elementi in posizione 0 e 3");
	SCLFun l3 = l2.removeElementAt(3).removeElementAt(0);
	System.out.print("l1 = ");
	l1.printSCL();
	System.out.print("l2 = ");
	l2.printSCL();
	System.out.print("l3 = ");
	l3.printSCL();

	System.out.println("\nRimuovo gli elemento J e K");
	SCLFun l4 = l3.removeElement("J").removeElement("K");
	System.out.print("l3 = ");
	l3.printSCL();
	System.out.print("l4 = ");
	l4.printSCL();

    }
}

