PDA

View Full Version : AIUTO IN JAVA


pinaciarli
08-04-2011, 10:33
LA TRACCIA E' LA SEGUENTE:
Si vuole scrivere una classe Java per la gestione del tipo Data (non è possibile utilizzare tipi già
definiti nelle librerie standard). In particolar la classe deve fornire:
a. un costruttore che prenda in input giorno, mese ed anno
b. un metodo getMonth che restituisca il nome del mese
c. un metodo isLeapYear che restituisca true se l’anno è bisestile, false altrimenti
d. un metodo addDays che prende in input un numero n ed incrementi la data di n giorni

IO HO STESO IL SEGUENTE CODICE:

class Data{
public int giorno;
public int mese;
public int anno;

public Data(int g, int m, int a)
{ this.giorno=g;
this.mese=m;
this.anno=a;
}

public String getMonth()
{
case 1 : return Gennaio;
case 2 : return Febbraio;
case 3 : return Marzo;
case 4 : return Aprile;
case 5: return Maggio;
case 6 : return Giugno;
case 7 : return Luglio;
case 8: return Agosto;
case 9 : return Settembre;
case 10 : return Ottobre;
case 11 : return Novembre;
case 12 : return Dicembre;
}
}

public bool isLeapYear(){
if(anno%4==0)
return true;
else
return false;
}

VOLEVO SAPERE SE HO FATTO QUALCHE ERRORE NELLA STESURA DEL COSICE E SOPRATTUTTO SE VA BENE...
POI, NON RIESCO A COSTRUIRE L'ULTIMO METODO, CIOE' IL PUNTO d.....SAPRESTE SPIEGARMELO??????????

GRAZIE MILLE

cionci
08-04-2011, 12:32
Thread chiuso
|
V
http://www.hwupgrade.it/forum/showthread.php?t=1649196