class Data {
  private int giorno;
  private int mese;
  private int anno;
  private String gsett;
  //Costruttore. Se viene richiamato in maniera errata viene generata un eccezione.
  public Data(int g, int m, int a, String gs) {
	if ((g<1) || (g>31)) throw new IllegalArgumentException("giorno errato");
	else giorno=g;
	if ((m<1) || (m>12)) throw new IllegalArgumentException("mese errato");
	else mese=m;
	if (a<0) throw new IllegalArgumentException("anno errato");
	else anno=a;
	gsett=gs;
  }
  //Metodi per leggere giorno mese anno e giornosettimana.
  public int getGiorno() { return giorno; }
  public int getMese() { return mese; }
  public int getAnno() { return anno; }
  public String getGiornoSettimana() { return gsett; }
  //Metodo equal.
  public boolean equal(Data d) {
	return ((this.giorno==d.giorno) && (this.mese==d.mese) && (this.anno==d.anno));
  }
  public int compareTo(Data d) {
	if (this.equal(d)) return 0;
	else {
	  if (this.getAnno()>d.getAnno()) return 1;
	  else if (this.getAnno()<d.getAnno()) return -1;
	  else {
        if (this.getMese()>d.getMese()) return 1;
        else if (this.getMese()<d.getMese()) return -1;
		else {
          if (this.getGiorno()>d.getGiorno()) return 1;
          else return -1;
		}
	  }
	}
  }
}