|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Junior Member
Iscritto dal: Apr 2011
Messaggi: 7
|
AIUTO IN JAVA
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 |
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 17:37.


















