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 > Problema CampoMinato
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
gattol
.novellino.

User info:
Registered: Sep 2010
Posts: 5 (0.00 al dì)
Location: Novara
Corso: Informatica
Anno: 1
Time Online: 0:51:23 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Problema CampoMinato

Salve a tutti, ho un problema con un programma (java), cercherò di essere breve.

Il testo del programma è questo:

http://homes.dsi.unimi.it/~fiorenti...campoMinato.txt

Io ho scritto la classe CampoMinato e fatto l'Esercizio1, entrambi vengono compilati senza problemi ma quando eseguo Esercizio1 mi da questi errori in esecuzione:

java Esercizio1 2 4
0 1 2 3 Exception in thread "main" java.util.IllegalFormatConversionException: d != java.lang.Character
at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:3999)
at java.util.Formatter$FormatSpecifier.printInteger(Formatter.java:2709)
at java.util.Formatter$FormatSpecifier.print(Formatter.java:2661)
at java.util.Formatter.format(Formatter.java:2433)
at java.io.PrintStream.format(PrintStream.java:920)
at java.io.PrintStream.printf(PrintStream.java:821)
at CampoMinato.stampa(CampoMinato.java:91)
at CampoMinato.stampaTutto(CampoMinato.java:62)
at Esercizio1.main(Esercizio1.java:7)


Questo è il sorgente di Esercizio1.java:

class Esercizio1{
public static void main(String[] args){
int r=Integer.parseInt(args[0]);
int c=Integer.parseInt(args[1]);
CampoMinato campo= new CampoMinato(r,c);
campo.stampaTutto();
}// end main
}// end class


Allego il sorgente della classe CampoMinato.java
Grazie a tutti!:)

Attachment: campominato.java
This has been downloaded 9 time(s).

21-02-2011 16:55
Click Here to See the Profile for gattol Click here to Send gattol a Private Message Find more posts by gattol Add gattol to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
CowBoy
.arcimaestro.

User info:
Registered: May 2006
Posts: 294 (0.04 al dì)
Location: Milano
Corso: F49 - Informatica
Anno: Laureato F49
Time Online: 3 Days, 13:40:27 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Prova a vedere questo confronto: d != ??? forse non hai usato gli appici... cmq vedo il testo e ti dico.

__________________
.. ±·ø·±-`` MuSiC iS My LanGuAGe ´´-±·ø·± ..

21-02-2011 17:03
Click Here to See the Profile for CowBoy Click here to Send CowBoy a Private Message Find more posts by CowBoy Add CowBoy to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
CowBoy
.arcimaestro.

User info:
Registered: May 2006
Posts: 294 (0.04 al dì)
Location: Milano
Corso: F49 - Informatica
Anno: Laureato F49
Time Online: 3 Days, 13:40:27 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Il problema è l'uso scorretto del COPIA/INCOLLA! :D

http://download.oracle.com/javase/1...ter.html#syntax

http://download.oracle.com/javase/1...eam.html#printf(java.lang.String, java.lang.Object...)

http://download.oracle.com/javase/1...rintStream.html

System.out.printf(" %2d", MINA_CHAR);
System.out.printf(" %2d", NONSC_CHAR);

MINA_CHAR e NONSC_CHAR sono caratteri, %2d è la formattazione per un intero... ecco la causa dell'eccezione.

code:
private void stampa(char cMina) { MINA_CHAR=cMina; //prima riga for (int pippo=0; pippo<colonne; pippo++) { System.out.printf(" %2d", pippo); } System.out.printf("\n"); //righe successive for (int j=1; j<righe; j++) { for (int o=0; o<righe; o++) { if (matr[j][o] == MINA) { System.out.printf(" %2c", MINA_CHAR); } else { System.out.printf(" %2c", NONSC_CHAR); } } System.out.printf("\n"); } }

__________________
.. ±·ø·±-`` MuSiC iS My LanGuAGe ´´-±·ø·± ..

Last edited by CowBoy on 21-02-2011 at 17:49

21-02-2011 17:33
Click Here to See the Profile for CowBoy Click here to Send CowBoy a Private Message Find more posts by CowBoy Add CowBoy to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
gattol
.novellino.

User info:
Registered: Sep 2010
Posts: 5 (0.00 al dì)
Location: Novara
Corso: Informatica
Anno: 1
Time Online: 0:51:23 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Che idiota. :)
Ora provo a mettere a posto. Grazie!

22-02-2011 09:04
Click Here to See the Profile for gattol Click here to Send gattol a Private Message Find more posts by gattol Add gattol to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
gianni.malvasi
.fedelissimo.

User info:
Registered: Mar 2007
Posts: 41 (0.01 al dì)
Location:
Corso:
Anno:
Time Online: 18:28:34 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Ragazzi sto facendo la classe CampoMinato...ho fatto i primi 2 esercizi...

non riesco a scrivere il metodo per scoprire le celle e aggiungere i numeri alle celle adiacenti alla mina...

qualcuno l'ha fatto???

17-05-2011 17:59
Click Here to See the Profile for gianni.malvasi Click here to Send gianni.malvasi a Private Message Find more posts by gianni.malvasi Add gianni.malvasi to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
terry
.amico.

User info:
Registered: Feb 2008
Posts: 38 (0.01 al dì)
Location:
Corso: comunicazione digitale
Anno:
Time Online: 10:46:16 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Ma questo è un'esercizio dell'esame di laboratorio o è un esame intero??

08-06-2011 10:58
Click Here to See the Profile for terry Click here to Send terry a Private Message Find more posts by terry Add terry to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
gattol
.novellino.

User info:
Registered: Sep 2010
Posts: 5 (0.00 al dì)
Location: Novara
Corso: Informatica
Anno: 1
Time Online: 0:51:23 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

@gianni.malvasi:
Io ne avevo fatto un pezzo ma l'ho abbandonato incompleto e non so neppure se giusto.

@terry:
Io l'ho trovato linkato sulla pagina dell'esame di prog I di Fiorentini (in realtà è nella cartella della Morpurgo) come esercizio da fare a casa in preparazione all'esame di laboratorio (in cui ci sono 4/5 esercizi molto più brevi).

08-06-2011 11:13
Click Here to See the Profile for gattol Click here to Send gattol a Private Message Find more posts by gattol Add gattol to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
terry
.amico.

User info:
Registered: Feb 2008
Posts: 38 (0.01 al dì)
Location:
Corso: comunicazione digitale
Anno:
Time Online: 10:46:16 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Graziee

08-06-2011 14:22
Click Here to See the Profile for terry Click here to Send terry a Private Message Find more posts by terry Add terry to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 22:00.    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.035 seconds (80.57% PHP - 19.43% MySQL) con 28 query.