
import java.util.*;

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


      // construct a Tutor object as nested inner class:
      Bonused expert = new Bonused()
        {  String name="Paolo Rossi";
           double frequency=80.;
           private double bonus=0.;

           public double getFrequency()
	     {

	        return frequency + bonus;
	     }

	   public void setBonus(double b)
	     {
	        bonus = b;
	     }
           GregorianCalendar calendar
             = new GregorianCalendar(2005, 10, 5);
           // GregorianCalendar uses 0 for January
           Date enrollmentDay = calendar.getTime();
        };
      // note that expert has the same methods of Student, but is not an instance of Student

      expert.setBonus(5);

      Student[] squadra = new Student[3];

      // fill the squadra array with Tutor and Student objects

      squadra[0] = expert; //Error: type mismatch!
      squadra[1] = new Student("Mario Bianchi", 70.,
         2000, 11, 1);
      squadra[2] = new Student("Carla Verdi", 60.,
         2000, 11, 1);

      // print out information about all Student objects
      for (int i = 0; i < squadra.length; i++)
      {
         Student e = squadra[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;
}

interface Bonused
{
	//public abstract Tutor(String n, double s,int year, int month, int day);
	public abstract double getFrequency();
	public abstract void setBonus(double b);
}

