
import java.util.*;

public class StudentTest_ArrayList
{
   public static void main(String[] args)
   {



      ArrayList squadra = new ArrayList();
      squadra.ensureCapacity(5);

	  //start a cronometer:
	  GregorianCalendar cronometer = new GregorianCalendar();
	  //double timeAtStart = cronometer.getTime(GregorianCalendar.MILLISECOND);
	  double timeAtStart = cronometer.getTime();

      squadra.add(new Student("Paolo Rossi", 80., 2000,11,1));
      squadra.add(new Student("Mario Bianchi", 70.,
         2000, 11, 1));
      squadra.add(new Student("Carla Verdi", 60.,
         2000, 11, 1));
 	  squadra.add(new Student("Umberto Neri", 60.,
         2000, 11, 1));
      squadra.add(new Student("Carlo Viola", 60.,
         2000, 11, 1));
      // print out information about all Student objects
         //Bonused e=(expert.getClass)squadra.get(1);
         //System.out.println("name=" + expert.getName() + ", frequency=" + expert.getFrequency());
      //double the size repeatedly:
      int volte=20;
      for (int j=0; j<volte; j++)
        {
			int numeroElementi = squadra.getSize();
         	for (int i=0; i<numeroElementi; i++)
				squadra.add(squadra.get(i));
	    }
      //double timeAtEnd = cronometer.getTime(GregorianCalendar.MILLISECOND);
      double timeAtEnd = cronometer.getTime();
      double timeElapsed = timeAtEnd-timeAtStart;
      NumberFormat quantiMillisecondi = NumberFormat.getTimeInstance();
      System.out.println(quantiMillisecondi.format(timeElapsed));

      /* for (int i = 1; i < squadra.size(); i++)
      {
         Student e = (Student)squadra.get(i);
         System.out.println("name=" + e.getName()
            + ", frequency=" + e.getFrequency());
      }*/
   }
}

class Student
{
   public Student(String n, double s,
      int year, int month, int day)
   {
      name = n;
      frequency = s;
      GregorianCalendar calendar
         = new GregorianCalendar(year, month - 1, day);
         // GregorianCalendar uses 0 for January
      enrollmentDay = calendar.getTime();
   }

   public String getName()
   {
      return name;
   }

   public double getFrequency()
   {
      return frequency;
   }

   public Date getEnrollmentDay()
   {
      return enrollmentDay;
   }

   public void raiseFrequency(double byPercent)
   {
      double raise = frequency * byPercent / 100;
      frequency += raise;
   }

   private String name;
   protected double frequency;
   private Date enrollmentDay;
}


