SimTest.java
Created with JBuilder
import es.*;
import java.util.*;
import java.io.*;

/**
 * SimTest Simula la realización de un Test
 *
 * @author Fco Gutiérrez MAQUINA: propia
 * @version 1.0 4/2/2001
 */
public class SimTest
{
    // variables de instancia
    private Test test;                // El test a realizar
    private SortedMap datosAlumnos;   // Tabla con los datos
    private Random rd;                // Variable aleatoria

    /**
     * Constructor para objetos de la clase SimTest
     * @param  t   Test con el que realizar la simulación
     */
    public SimTest(Test t)
    {
        // initializa las variables de instancia
        test = t;
        rd = new Random();
    }

    /**
     * simula   Realiza una simulación de la ejecución de un test
     *
     * @param  nv   Numero de alumnos que simulan examinarse del test
     * @return
     */
    public void simula(int nv) throws Exception {
        datosAlumnos = new TreeMap(); // Borra datos anteriores
        for (int i=0;i<nv;i++) {
            // Genera un alumno
            Alumno a = genera(test.numModelos(),test.numPreguntas());
            // Lo examina
            int puntos = a.corrige(test);
            // Acumula sus datos
            acumula(puntos);
        }
    }

    /**
     * genera    Genera un alumno de forma aleatoria
     *
     * @param  nm   Numero de modelos
     * @param  nr   Numero de preguntas por modelo
     * @return      El alumno generado
     */
    private Alumno genera(int nm, int np) {
        int numMod = 1+rd.nextInt(nm);
        String resp="";
        for(int x=0;x<np;x++) {
            resp=resp+"ABCD ".charAt(rd.nextInt(5));
        }
        return new Alumno("Fco. Gutiérrez",numMod,resp);
    }

    /**
     * acumula       Acumula la puntuación dada
     *
     * @param  ptos  Los puntos a acumular
     * @return
     */
    private void acumula(int ptos) {
        Integer ptosI = new Integer(ptos);
        Integer na = (Integer)datosAlumnos.get(ptosI);
        if (na==null) {
            na = new Integer(0);
        }
        datosAlumnos.put(ptosI,new Integer(1+na.intValue()));
    }

    /**
     * listado     Lista los datos de la simulación
     *
     * @param  pw  Flujo por el que saldrá el listado
     * @return
     */
    public void listado(PrintWriter pw) {
        ES.writeString("Puntuación",12,ES.LEFT);
        ES.writeStringLn("Num. Alumnos",20,ES.LEFT);
        Iterator it = datosAlumnos.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry me = (Map.Entry) it.next();
            Integer ptosI = (Integer)me.getKey();
            Integer numA  = (Integer)me.getValue();
            ES.writeInt(ptosI.intValue(),5);
            ES.writeIntLn(numA.intValue(),10);
        }
    }

    /**
     * main     Ejemplo de prueba de la simulación
     *
     * @return
     */
    static public void main(String [] args) throws Exception {
        // Se genera el test
        Test test = new Test(4,12);
        // con estas respuestas correctas
        test.respModelo(1,"ABBACDDCABCD");
        test.respModelo(2,"BBBAAACCCDDD");
        test.respModelo(3,"CDCDACACBBAA");
        test.respModelo(4,"AABBAACCAADD");

        // Se crea un objeto simulación
        SimTest st = new SimTest(test);
        // Se simula con 200 alumnos
        st.simula(200);
        // Se establece como flujo de salida, la salida standar
        PrintWriter pw = new PrintWriter(System.out,true);
        // Y se saca el listado
        st.listado(pw);
    }

}


SimTest.java
Created with JBuilder