Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Didattica > Corsi N - Z > Programmazione > Dubbio compitino Alberti
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
PrizeD
.consigliere.

User info:
Registered: Dec 2007
Posts: 140 (0.02 al dì)
Location: Cerro Maggiore
Corso: Informatica
Anno:
Time Online: 20:00:39 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Dubbio compitino Alberti

Ragazzi mi è venuto un dubbio sullo svolgimento di questo esercizio; la prof ha messo una soluzione sul sito (ecco giusto quello che ci interessa) che però secondo me da un errore quando viene eseguito next() per la 13 volta visto che l'array anno[] ha 12 posizioni.



Implementare i metodi hasNext()e next()dell’interfaccia Iterator del package java.util sulla struttura dati contenente i mesi dell’anno (si noti che l’implementazione del metodo public void remove () è richiesta dall’interfaccia Iterator ma non da questo esercizio):

public class IteratorDemo implements java.util.Iterator {

private String[] anno = {"gen","feb","mar","apr","mag","giu","lug" ,“ago”,“set”,“ott”,“nov”,“dic”
};
private int mese = 0;

public void remove () {}

public boolean hasNext() {



}

public Object next() {



}
}




io ho fatto così :



public Object next() {

return anno[(this.values()+1) %12];

}
}


che una volta arrivato alla fine dell'array ricomincia dal primo.


Boh nn capisco, aiutatemi voi :D

grazie

Last edited by PrizeD on 09-02-2008 at 12:18

08-02-2008 19:17
Click Here to See the Profile for PrizeD Click here to Send PrizeD a Private Message Find more posts by PrizeD Add PrizeD to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
PrizeD
.consigliere.

User info:
Registered: Dec 2007
Posts: 140 (0.02 al dì)
Location: Cerro Maggiore
Corso: Informatica
Anno:
Time Online: 20:00:39 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

up

09-02-2008 12:19
Click Here to See the Profile for PrizeD Click here to Send PrizeD a Private Message Find more posts by PrizeD Add PrizeD to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
PrizeD
.consigliere.

User info:
Registered: Dec 2007
Posts: 140 (0.02 al dì)
Location: Cerro Maggiore
Corso: Informatica
Anno:
Time Online: 20:00:39 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

nooo...non mi sono accorto. :D
this.values() darebbe errore perche' values() non e' definito per la classe IteratorDemo

12-02-2008 18:13
Click Here to See the Profile for PrizeD Click here to Send PrizeD a Private Message Find more posts by PrizeD Add PrizeD to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 15:48.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.038 seconds (55.90% PHP - 44.10% MySQL) con 28 query.