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 > [Progetto] "Commesso viaggiatore"
Pages (8): « 1 2 [3] 4 5 6 7 » ... Last »   Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
Simeon
:D

User info:
Registered: Aug 2004
Posts: 984 (0.13 al dì)
Location: Milano
Corso: Informatica
Anno: IT IS OVER!
Time Online: 14 Days, 19:29:42 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Artanis
...Oppure bisogna usare l'oggetto list (Che non conosco perchè ho saltato la lezione dedicata)?


Io ti suggerisco di guardare qualcosa sulle List, scaricati i pdf della lezione 7 del Grossi dal suo sito ;)

Potresti anche fare lo sforzo di leggerti i post precedenti si sto thread cmq, c'e la risposta a questa tua domanda.

17-01-2005 22:38
Click Here to See the Profile for Simeon Click here to Send Simeon a Private Message Find more posts by Simeon Add Simeon to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Artanis
Dark Sith Lord

User info:
Registered: Aug 2004
Posts: 108 (0.01 al dì)
Location: Inzago
Corso: Informatica
Anno: 3
Time Online: 11:58:38 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Grazie, cercherò subito!

P.S. Come mai il primo progettino era uno scherzo da un'oretta, mentre questo è così sproporzionato? O è soltanto il primo impatto e poi il progetto fila liscio?

;)

__________________
Artanis

http://artanis.myblog.it/

17-01-2005 22:46
Click Here to See the Profile for Artanis Click here to Send Artanis a Private Message Visit Artanis's homepage! Find more posts by Artanis Add Artanis to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Jacoposki
.arcimaestro.

User info:
Registered: Sep 2004
Posts: 498 (0.07 al dì)
Location: Milano
Corso: Informatica
Anno: in tesi-sa dio per quanto
Time Online: 4 Days, 0:36:57 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

secondo me oltre al nome, alla nuova città devi passare la mappa in cui la inserisci, da cui poi il costruttore della nuova città andrà a prendere i dati necessari a costruire la lista distanze della nuova città.

o sto dicendo boiate senza senso? :?

__________________
Mai sottovalutare l'ampiezza di banda di una station wagon piena di nastri lanciata a tutta velocità lungo l'autostrada. - Andrew S. Tanenbaum - Reti di Calcolatori

18-01-2005 01:29
Click Here to See the Profile for Jacoposki Click here to Send Jacoposki a Private Message Visit Jacoposki's homepage! Find more posts by Jacoposki Add Jacoposki to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Diuzza
.illuminato.

User info:
Registered: Aug 2004
Posts: 169 (0.02 al dì)
Location:
Corso: Informatica
Anno: 2
Time Online: 1 Day, 8:30:45 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Scusate ma dato che il programma deve leggere i dati delle città e delle distanze da un file devo usare uno stream?

18-01-2005 09:29
Click Here to See the Profile for Diuzza Click here to Send Diuzza a Private Message Find more posts by Diuzza Add Diuzza to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
AlVin
.primate.

User info:
Registered: Sep 2004
Posts: 71 (0.01 al dì)
Location: Milano
Corso: Informatica
Anno: Terzo
Time Online: 1 Day, 0:25:12 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Diuzza
Scusate ma dato che il programma deve leggere i dati delle città e delle distanze da un file devo usare uno stream?

Ma forse basta usare FileInputManager no??

oh domanda da un milione di dollari: cosa significa che il metodo elencaCitta deve restituire un iterator sull'insieme di città?? iterator non è una interfaccia?? non capisco cosa vuol dire!

18-01-2005 11:47
Click Here to See the Profile for AlVin Click here to Send AlVin a Private Message Find more posts by AlVin Add AlVin to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Diuzza
.illuminato.

User info:
Registered: Aug 2004
Posts: 169 (0.02 al dì)
Location:
Corso: Informatica
Anno: 2
Time Online: 1 Day, 8:30:45 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Lo stavo guardando anche io. Dice che la maggior parte delle classi implementano l'interfaccia ma a quanto ho visto string no. e quindi? come faccio ad utilizzarlo

18-01-2005 11:49
Click Here to See the Profile for Diuzza Click here to Send Diuzza a Private Message Find more posts by Diuzza Add Diuzza to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
AlVin
.primate.

User info:
Registered: Sep 2004
Posts: 71 (0.01 al dì)
Location: Milano
Corso: Informatica
Anno: Terzo
Time Online: 1 Day, 0:25:12 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Allora se ho capito bene la mappa dovrebbe essere una struttura dinamica (io ho usato un arrayList) contenente tot oggetti di tipo città (e ogni città ha come campi il nome e le distanze).
Quindi restituire un iterator sull'insieme di città presenti nella mappa significa semplicemente far restituire alla funzione elencaCittà "mappa.iterator()"?? è così banale?

18-01-2005 12:00
Click Here to See the Profile for AlVin Click here to Send AlVin a Private Message Find more posts by AlVin Add AlVin to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Diuzza
.illuminato.

User info:
Registered: Aug 2004
Posts: 169 (0.02 al dì)
Location:
Corso: Informatica
Anno: 2
Time Online: 1 Day, 8:30:45 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Si, se tu hai fatto così sì

Io ho fatto diversamente ma ho un quesito:

ArreyList implementa l'interfaccia iterator?

18-01-2005 12:11
Click Here to See the Profile for Diuzza Click here to Send Diuzza a Private Message Find more posts by Diuzza Add Diuzza to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
AlVin
.primate.

User info:
Registered: Sep 2004
Posts: 71 (0.01 al dì)
Location: Milano
Corso: Informatica
Anno: Terzo
Time Online: 1 Day, 0:25:12 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

java.util
Class ArrayList

Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList
;)

18-01-2005 12:15
Click Here to See the Profile for AlVin Click here to Send AlVin a Private Message Find more posts by AlVin Add AlVin to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Artanis
Dark Sith Lord

User info:
Registered: Aug 2004
Posts: 108 (0.01 al dì)
Location: Inzago
Corso: Informatica
Anno: 3
Time Online: 11:58:38 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Ragazzi, ma nel costruttore di Città, oltre alla stringa per il nome, gli si deve passare un array di interi o un arrayList di Integer? In entrambi i casi, nel costruttore di città non dobbiamo preoccuparci di cosa contiene, ci penserà l'utente che usa l'oggetto Citta a inserire i dati correttamente, giusto?

__________________
Artanis

http://artanis.myblog.it/

18-01-2005 14:02
Click Here to See the Profile for Artanis Click here to Send Artanis a Private Message Visit Artanis's homepage! Find more posts by Artanis Add Artanis to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Diuzza
.illuminato.

User info:
Registered: Aug 2004
Posts: 169 (0.02 al dì)
Location:
Corso: Informatica
Anno: 2
Time Online: 1 Day, 8:30:45 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Il prof ha detto che la classe città viene costruita liberamente da parte dell'utente.

18-01-2005 14:43
Click Here to See the Profile for Diuzza Click here to Send Diuzza a Private Message Find more posts by Diuzza Add Diuzza to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Diuzza
.illuminato.

User info:
Registered: Aug 2004
Posts: 169 (0.02 al dì)
Location:
Corso: Informatica
Anno: 2
Time Online: 1 Day, 8:30:45 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Ho una domanda.

Se ho una classe publica posso accedere direttamente ai suoi campi da qualunque classe vero?

Perchè se ho un arraylist ciao= new arrayList(), per prendere un oggetto in una determinata posizione devo fare ciao.get(posizione)

e se ad esempio al'interno dell'arrayList ho una frazione per accedere al numeratore io farei:

(Frazione(ciao.get(posizione))).num

Perchè il risultato del get è di tipo object.

Ma non va...

18-01-2005 15:06
Click Here to See the Profile for Diuzza Click here to Send Diuzza a Private Message Find more posts by Diuzza Add Diuzza to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Artanis
Dark Sith Lord

User info:
Registered: Aug 2004
Posts: 108 (0.01 al dì)
Location: Inzago
Corso: Informatica
Anno: 3
Time Online: 11:58:38 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Ragazzi, ho un altro dubbio. Stavo facendo delle prove per la creazione di un file mappa e sono riuscito a fare in modo di salvare direttamente un oggetto ArrayList per poi ricaricarlo facilmente dal file. Il problema è che aprendo il file mappa.txt non c'è più il testo semplice "AG 0 32 38" ma gli oggetti che ho effettivamente salvato.

È obbligatorio che la mappa sia, diciamo, leggibile anche aprendolo con il notepad o è importante solo che sia leggibile (e scrivibile) all'interno del programma?

__________________
Artanis

http://artanis.myblog.it/

18-01-2005 15:52
Click Here to See the Profile for Artanis Click here to Send Artanis a Private Message Visit Artanis's homepage! Find more posts by Artanis Add Artanis to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
nfast
.precettore.

User info:
Registered: Sep 2004
Posts: 95 (0.01 al dì)
Location:
Corso: Informatica
Anno: primo
Time Online: 18:00:55 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

rispondo a molti vostri dubbi...

per Diuzza:

il metodo get(int x) restituisce un oggetto,quindi per far si di renderlo compatibile devi fare un cast forzata

List listadint = new ArrayList();
........
for(int pos = 0;pos < listadint.size();pos++)
Integer i = (Integer)listadint.get(pos);

supposto vero che l'oggetto estratto dal metodo get sia un'istanza di Integer.

per accedere invece ad una variabile all'interno di un oggetto, consiglio di usare i metodi implementati dalla classe:
ad esempio nella classe Frazione.....

int num = (Frazione)lista.get(pos).getNumeratore();

:)

per Artanis....

meglio salvare su un file di testo sotto forma di stringa.

ad esempio il metodo salva carichera il testo da salvare sotto forma di stringa e tramite i metodi di FileOutputStream (vedi il metodo print(String testo), salvi su file.

;)

per il costruttore Citta si possono scegliere diverse strade:
passargli un ArrayList e la sigla sotto forma di stringa, oppure un array di Integer (Integer[]..) e la solita sigla (nome citta) oppure un array di interi (int[]) oppure una Citta ....

sei libero di scegliere ciò che vuoi....

ciaoz...

PS: un saluto a Simeon e a Jakoposki.... (ma che fine ha fatto IanStillo ?)

18-01-2005 16:51
Click Here to See the Profile for nfast Click here to Send nfast a Private Message Find more posts by nfast Add nfast to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
nfast
.precettore.

User info:
Registered: Sep 2004
Posts: 95 (0.01 al dì)
Location:
Corso: Informatica
Anno: primo
Time Online: 18:00:55 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

ah dimeticavo ecco un esempio di esecuzione del progetto:
C:\j2sdk1.4.1_02\prog\prog2>java testCitta
Inserisci nome da assegnare alla mappa: xxxxxx
Inserisci il nome del file da caricare: mappa.txt
Ecco la mappa creata:
AG 0 10 20 40 40 60 10 60 30
BO 10 0 40 20 50 90 20 40 90
CH 20 40 0 10 20 50 10 70 80
FI 40 20 10 0 10 30 70 30 30
GE 40 50 20 10 0 40 70 30 90
PR 60 90 50 30 40 0 50 20 10
RT 10 20 10 70 70 50 0 60 50
SI 60 40 70 30 30 20 60 0 10
TR 30 90 80 30 90 10 50 10 0

Inserisci nome citta' da aggiungere alla mappa: MI
Distanza da AG: 20
Distanza da BO: 30
Distanza da CH: 10
Distanza da FI: 15
Distanza da GE: 35
Distanza da PR: 80
Distanza da RT: 50
Distanza da SI: 30
Distanza da TR: 20
............
Inserisci citta' da ricercare nel tour: MI
Nome citta: MI
Distanze: 20 30 10 15 35 80 50 30 20 0
Calcola distanza tra due citta'
Inserisci citta'1: MI
Inserisci citta'2: CH
La distanza tra MI e CH e' di 10
Inserisci il nome della citta' da cui iniziare il tour: CH
CH-RT-PR-AG-SI-FI-BO-TR-MI-GE-CH
Lunghezza totale del tour: 395
Nome della citta' che ha la somma delle distanze dalle altre citta'
minore della somma delle distanze di ogni altra citta': MI
Nome della citta' che ha la somma delle distanze dalle altre citta'
maggiore della somma delle distanze di ogni altra citta': AG
AG 0 10 20 40 40 60 10 60 30 20
BO 10 0 40 20 50 90 20 40 90 30
CH 20 40 0 10 20 50 10 70 80 10
FI 40 20 10 0 10 30 70 30 30 15
GE 40 50 20 10 0 40 70 30 90 35
PR 60 90 50 30 40 0 50 20 10 80
RT 10 20 10 70 70 50 0 60 50 50
SI 60 40 70 30 30 20 60 0 10 30
TR 30 90 80 30 90 10 50 10 0 20
MI 20 30 10 15 35 80 50 30 20 0

Inserisci il nome del file per salvare: test.txt

:)

ciao di nuovo

18-01-2005 16:56
Click Here to See the Profile for nfast Click here to Send nfast a Private Message Find more posts by nfast Add nfast to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 19:40.    Post New Thread    Post A Reply
Pages (8): « 1 2 [3] 4 5 6 7 » ... 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.109 seconds (57.19% PHP - 42.81% MySQL) con 23 query.