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 su array Orario [] tempi
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
albakiara
.illuminato.

User info:
Registered: Sep 2010
Posts: 157 (0.03 al dì)
Location: Pavia
Corso: informatica
Anno: 3
Time Online: 19:31:35 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
dubbio su array Orario [] tempi

Salve a tutti,
dovrei creare e inizializzare quell'array con questi orari:
12:00, 2:05, 10:15

io ho fatto così, però mi dà errori:
Orario[] tempi = {new Orario(2:05), new Orario(10:15), new Orario (12:00) };

cosa sbaglio? :(

19-11-2011 09:08
Click Here to See the Profile for albakiara Click here to Send albakiara a Private Message Find more posts by albakiara Add albakiara 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 costruttore Orario che tipo di variabile prende come parametro? Hai una descrizione della classe Orario?

Constructor Summary
Orario()
Costruisce un nuovo orario che rappresenta l'orario attuale, cioè l'orario relativo all'istante in cui viene invocato.
Orario(int hh, int mm)
Costruisce un nuovo orario a partire dai due argomenti specificati che rappresentano, nell'ordine, ore e minuti.
Orario(java.lang.String s)
Costruisce un nuovo orario a partire dalla stringa specificata come argomento nel formato "hh:mm".



http://pighizzini.dico.unimi.it/jb/...ili/Orario.html

Prova a modificarlo così:

Orario[] tempi = { new Orario("02:05"), new Orario("10:15"), new Orario("12:00") };

oppure singolarmente:

Orario[] tempi = new Orario[3];
tempi[0] = new Orario("02:05");
tempi[1] = new Orario("10:15");
tempi[2] = new Orario("12:00");

Ciao!

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

Last edited by CowBoy on 21-11-2011 at 14:12

19-11-2011 10:39
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
lektronar
.fedelissimo.

User info:
Registered: May 2010
Posts: 59 (0.01 al dì)
Location: Arese
Corso: Informatica
Anno: 3
Time Online: 6:09:54 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

il problema è la stringa, il costruttore col formato hh:mm vuole un letterale stringa.

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

User info:
Registered: Sep 2010
Posts: 157 (0.03 al dì)
Location: Pavia
Corso: informatica
Anno: 3
Time Online: 19:31:35 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

potresti scrivere il codice? grazie

21-11-2011 10:01
Click Here to See the Profile for albakiara Click here to Send albakiara a Private Message Find more posts by albakiara Add albakiara 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 in modo sintetico si chiama "doppio apice non formattato" :)
hh:mm vuol dire che devi passare una stringa di 5 caratteri, mentre 2:05 ne ha solo 4. Per rispettare il formato devi inserire "02:05".

code:
import prog.utili.*; class Prova { public static void main() { Orario[] tempi = { new Orario( "02:05" ), new Orario( "10:15" ), new Orario( "12:00" ) }; for ( int i = 0; i < 3; i++ ) System.out.println( tempi[i].toString() ); } }

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

Last edited by CowBoy on 21-11-2011 at 14:10

21-11-2011 13:53
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
oksana213
.amico.

User info:
Registered: May 2008
Posts: 23 (0.00 al dì)
Location:
Corso:
Anno:
Time Online: 15:04:37 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
codice

class Soluzione{



public static void main (String [] args){

String [] temp = {new String ("12:05"), new String ("2:05"), new

String ("10:15")};



for (int i=0; i<3; i++)
System.out.print(temp[i].toString() + " ");
System.out.println();

}

}

21-11-2011 14:01
Click Here to See the Profile for oksana213 Click here to Send oksana213 a Private Message Find more posts by oksana213 Add oksana213 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
Re: codice

Originally posted by oksana213
class Soluzione{



public static void main (String [] args){

String [] temp = {new String ("12:05"), new String ("2:05"), new

String ("10:15")};



for (int i=0; i<3; i++)
System.out.print(temp[i].toString() + " ");
System.out.println();

}

}


Ma l'oggetto non era di tipo Orario?

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

Last edited by CowBoy on 21-11-2011 at 14:08

21-11-2011 14: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
albakiara
.illuminato.

User info:
Registered: Sep 2010
Posts: 157 (0.03 al dì)
Location: Pavia
Corso: informatica
Anno: 3
Time Online: 19:31:35 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

si appunto :-)

21-11-2011 19:20
Click Here to See the Profile for albakiara Click here to Send albakiara a Private Message Find more posts by albakiara Add albakiara 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 codice che ti ho postato sopra l'ho provato e funziona. Se hai dei problemi di questo tipo il mio suggerimento è di guardare subito le API delle classi coinvolte.

Ciao! :)

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

22-11-2011 09:04
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
lektronar
.fedelissimo.

User info:
Registered: May 2010
Posts: 59 (0.01 al dì)
Location: Arese
Corso: Informatica
Anno: 3
Time Online: 6:09:54 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Non c'entra nulla l'apice non formattato etc... è solo che non passava un tipo argomento corretto, ovvero mancavano i doppi apici. Non è richiesto lo '0' davanti a ore minori di 10.

23-11-2011 04:01
Click Here to See the Profile for lektronar Click here to Send lektronar a Private Message Find more posts by lektronar Add lektronar 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

mmm... allora avrò una vecchia versione della classe Orario, perché a me mi dava un errore se mettevo "2:10" al posto di "02:10".

Problema risolto cmq!

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

23-11-2011 08:32
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
All times are GMT. The time now is 12:18.    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.387 seconds (21.70% PHP - 78.30% MySQL) con 27 query.