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 A - F > Fondamenti di architettura e programmazione > [HASHTABLE] Help
Pages (8): « 1 [2] 3 4 5 6 » ... Last »   Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
sandrino83
maschio latino

User info:
Registered: Oct 2004
Posts: 376 (0.05 al dì)
Location:
Corso: Com Dig
Anno: finito
Time Online: 8 Days, 7:53:08: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

certo

__________________
we are just two lost souls swimming in a fish bowl year after year....running over the same old ground....what have we found.......

26-01-2006 15:06
Click Here to See the Profile for sandrino83 Click here to Send sandrino83 a Private Message Find more posts by sandrino83 Add sandrino83 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Joda
.grande:maestro.

User info:
Registered: Mar 2003
Posts: 1126 (0.14 al dì)
Location: Milano
Corso: Dottore in Informatica
Anno: Primo TICOM
Time Online: 9 Days, 23:17:40 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by sandrino83
certo


:pensa: potresti postare l'intero codice della classe ?

__________________
Homepage personale (English version)
c/o segreteria didattica via comelico

26-01-2006 15:13
Click Here to See the Profile for Joda Click Here to See the Blog of Joda Click here to Send Joda a Private Message Visit Joda's homepage! Find more posts by Joda Add Joda to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
sandrino83
maschio latino

User info:
Registered: Oct 2004
Posts: 376 (0.05 al dì)
Location:
Corso: Com Dig
Anno: finito
Time Online: 8 Days, 7:53:08: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

public abstract class Istruzione{

Hashtable<String,Integer> hashtable = new Hashtable<String,Integer>();

hashtable.put("three", 3);

public abstract void esegui();

...
}


Logicamente ho usato l metodo put in questa classe solo a livello di test, ma anche mettendolo nelle classi estese il risultato non cambia


Intervento del moderatore:
Post "ritoccato", codice eccessivo

__________________
we are just two lost souls swimming in a fish bowl year after year....running over the same old ground....what have we found.......

Last edited by ciops on 01-02-2006 at 16:05

26-01-2006 15:38
Click Here to See the Profile for sandrino83 Click here to Send sandrino83 a Private Message Find more posts by sandrino83 Add sandrino83 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Reaper
Maestro Jedi

User info:
Registered: Oct 2005
Posts: 362 (0.05 al dì)
Location: Patagonia
Corso: ComDig
Anno: MOoooLto InDieTRO...
Time Online: 1 Day, 16:04:39 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

.........mannaggia la p......a............... :)

cosa usi per stendere il testo del programma? jcreator anke tu? :)

26-01-2006 15:43
Click Here to See the Profile for Reaper Click here to Send Reaper a Private Message Find more posts by Reaper Add Reaper to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
sandrino83
maschio latino

User info:
Registered: Oct 2004
Posts: 376 (0.05 al dì)
Location:
Corso: Com Dig
Anno: finito
Time Online: 8 Days, 7:53:08: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

si perchè?

__________________
we are just two lost souls swimming in a fish bowl year after year....running over the same old ground....what have we found.......

26-01-2006 15:47
Click Here to See the Profile for sandrino83 Click here to Send sandrino83 a Private Message Find more posts by sandrino83 Add sandrino83 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Joda
.grande:maestro.

User info:
Registered: Mar 2003
Posts: 1126 (0.14 al dì)
Location: Milano
Corso: Dottore in Informatica
Anno: Primo TICOM
Time Online: 9 Days, 23:17:40 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by sandrino83
public abstract class Istruzione{

Hashtable<String,Integer> hashtable = new Hashtable<String,Integer>();

hashtable.put("three", 3);


....

}


Logicamente ho usato l metodo put in questa classe solo a livello di test, ma anche mettendolo nelle classi estese il risultato non cambia


Ho capito dove sbagli ...

Definizione di classe
Una classe può essere pubblica, privata, astratta e può estendere e/o implementare altre classi.

Ho visto che definisci una classe astratta, dunque...

Classi Astratte

le classi astratte si definiscono nel seguente modo :


public abstract NOMECLASSE {
dichiarare i metodi
}


Una classe astratta può contenere sia metodi astratti che statici.

metodi statici
I metodi statici sono quelli di cui viene definito il codice.

Esempio
code:
public void metodo() { codice metodo }


metodi astratti
I metodi astratti sono i metodi, la cui implementazione è lasciata allo sviluppatore, un pò come succede per le Interfacce.

Esempio di dichiarazione
code:
public void metodo() {} ;


Hashtable

la riga

code:
hashtable.put(chiave,valore);


la devi scrivere o nel metodo costruttore o in un metodo statico.

Metodo Costruttore

public class ClasseProva {
public ClasseProva() {
hashtable.put(chiave,valore);
}
}

Metodo statico
public class ClasseProva {
public ClasseProva() {
}

public void metodo_statico() {
hashtable.put(chiave,valore);
}
}

IDE Java

Di IDE Java ce ne sono differenti, comunque personalmente io consiglierei o netbeans oppure eclipse

__________________
Homepage personale (English version)
c/o segreteria didattica via comelico

Last edited by ciops on 01-02-2006 at 16:05

26-01-2006 16:36
Click Here to See the Profile for Joda Click Here to See the Blog of Joda Click here to Send Joda a Private Message Visit Joda's homepage! Find more posts by Joda Add Joda to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
sandrino83
maschio latino

User info:
Registered: Oct 2004
Posts: 376 (0.05 al dì)
Location:
Corso: Com Dig
Anno: finito
Time Online: 8 Days, 7:53:08: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

grazie mille per i consigli....proverò......

__________________
we are just two lost souls swimming in a fish bowl year after year....running over the same old ground....what have we found.......

26-01-2006 16:42
Click Here to See the Profile for sandrino83 Click here to Send sandrino83 a Private Message Find more posts by sandrino83 Add sandrino83 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
zyx
.consigliere.

User info:
Registered: Nov 2005
Posts: 127 (0.02 al dì)
Location: Ceriano Laghetto
Corso: comunicazione digitale
Anno: 2° anno
Time Online: 1 Day, 14:12:42 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Io volevo chiedere una cosa. In istruzione dichiaro una Hashtable, che non costruisco, ma che non posso costruire neanche nelle varie classi estese, perchè ogni qualvolta costruisco una di queste classi mi si costruisce anche una nuova Hashtable. Invece il mio scopo è quello di costruire una Hashtable condivisa da tutte le classi. Come posso fare?

26-01-2006 18:38
Click Here to See the Profile for zyx Click here to Send zyx a Private Message Find more posts by zyx Add zyx to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Joda
.grande:maestro.

User info:
Registered: Mar 2003
Posts: 1126 (0.14 al dì)
Location: Milano
Corso: Dottore in Informatica
Anno: Primo TICOM
Time Online: 9 Days, 23:17:40 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by zyx
Io volevo chiedere una cosa. In istruzione dichiaro una Hashtable, che non costruisco, ma che non posso costruire neanche nelle varie classi estese, perchè ogni qualvolta costruisco una di queste classi mi si costruisce anche una nuova Hashtable. Invece il mio scopo è quello di costruire una Hashtable condivisa da tutte le classi. Come posso fare?


scusa ma non ho capito potresti spiegare meglio ?

__________________
Homepage personale (English version)
c/o segreteria didattica via comelico

26-01-2006 18:45
Click Here to See the Profile for Joda Click Here to See the Blog of Joda Click here to Send Joda a Private Message Visit Joda's homepage! Find more posts by Joda Add Joda to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
unid
.consigliere.

User info:
Registered: Nov 2005
Posts: 123 (0.02 al dì)
Location:
Corso: Laureato
Anno: Laureato
Time Online: 22:18:48 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Sequenza

1- Secondo me la parte più difficile è l'implementazione della classe sequenza e del suo clone();
Una volta fatta quella si è a metà dell'opera....
Qualcuno l'ha già fatta??

2- Rispondo a qui sopra: Se dichiari l'hashtable nella classe astratta Istruzione e le altre classi le estendi da questa... anche le altre classi ereditano la stessa hashtable..

abstract class Istruzione implements Cloneable{

Hashtable<String,Integer> memoria = new Hashtable<String,Integer>();

public abstract void esegui() throws ExecutionException;

public abstract Object clone();

public abstract String toString();

}

poi dalle altre classi ci accedi tranquillamente così:

Integer temp = (Integer)memoria.get(variabile);
memoria.put(variabile, new Integer(valore));

a seconda di quello che devi fare...

26-01-2006 19:01
Click Here to See the Profile for unid Click here to Send unid a Private Message Visit unid's homepage! Find more posts by unid Add unid to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
zyx
.consigliere.

User info:
Registered: Nov 2005
Posts: 127 (0.02 al dì)
Location: Ceriano Laghetto
Corso: comunicazione digitale
Anno: 2° anno
Time Online: 1 Day, 14:12:42 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Si ma se faccio così come hai detto ora ogni volta che "programma.java" costruisce un istruzione(che può essere una qualsiasi di quelle da implementare) viene costruito anche un nuovo hashtable cosicchè io ho tanti Hashtable quante sono le "istruzioni" costruite. Invece bisogna avere un solo Hashtable che venga condiviso da tutte le "istruzioni"

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

User info:
Registered: Nov 2005
Posts: 127 (0.02 al dì)
Location: Ceriano Laghetto
Corso: comunicazione digitale
Anno: 2° anno
Time Online: 1 Day, 14:12:42 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Quello che voglio cercare di capire io è: come creare un solo "Hashtable<String,Integer> memoria" dove però tutte le istruzioni possono scriverci e leggerci

26-01-2006 19:29
Click Here to See the Profile for zyx Click here to Send zyx a Private Message Find more posts by zyx Add zyx to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
zyx
.consigliere.

User info:
Registered: Nov 2005
Posts: 127 (0.02 al dì)
Location: Ceriano Laghetto
Corso: comunicazione digitale
Anno: 2° anno
Time Online: 1 Day, 14:12:42 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Per quanto riguarda la classe Sequenza io ho dichiarato un oggetto array. Ad esempio Array array. poi nel costruttore ho fatto elenco=e e poi un int arrayLength=array.length(elenco) così so quanti elementi ci sono nell'array.Poi nel metodo esegui ho fatto un for da 0 a arrayLength, e nel corpo del for ho fatto elenco[i].esegui. Credo e spero sia giusto.

26-01-2006 19:34
Click Here to See the Profile for zyx Click here to Send zyx a Private Message Find more posts by zyx Add zyx to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
unid
.consigliere.

User info:
Registered: Nov 2005
Posts: 123 (0.02 al dì)
Location:
Corso: Laureato
Anno: Laureato
Time Online: 22:18:48 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Non crea altre hashtable, usa sempre la stessa... importante è che le sottoclassi estendano tutte Istruzione.

Il metodo clone non l'hai implementato??

26-01-2006 20:26
Click Here to See the Profile for unid Click here to Send unid a Private Message Visit unid's homepage! Find more posts by unid Add unid to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Joda
.grande:maestro.

User info:
Registered: Mar 2003
Posts: 1126 (0.14 al dì)
Location: Milano
Corso: Dottore in Informatica
Anno: Primo TICOM
Time Online: 9 Days, 23:17:40 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

per quanto riguarda l'hashtable, potresti creare una classe che la istanzi (una volta sola), poi passi l'oggetto alle successive classi che vengono create.

__________________
Homepage personale (English version)
c/o segreteria didattica via comelico

26-01-2006 20:26
Click Here to See the Profile for Joda Click Here to See the Blog of Joda Click here to Send Joda a Private Message Visit Joda's homepage! Find more posts by Joda Add Joda to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 06:49.    Post New Thread    Post A Reply
Pages (8): « 1 [2] 3 4 5 6 » ... Last »   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.117 seconds (48.02% PHP - 51.98% MySQL) con 24 query.