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 > [JAVA][HELP] Eccezioni
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
K)M4STER
.precettore.

User info:
Registered: Nov 2004
Posts: 96 (0.01 al dì)
Location:
Corso:
Anno:
Time Online: 1 Day, 0:40:10 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Eccezioni Java

Mi servirebbe un aiuto per risolvere il seguente problema,
amettiamo che un metodo o un costruttore di una certa classe se si verifica una determinata condizione lanci l'eccezione Exception1. Quello che mi servirebbe è vedere, in un altro metodo (o in un costruttore), se Excpetion1 è stata effettivamente lanciata...

Faccio un esempio per chiarire:

class Prova throws Exception1
{ Exception1 e1 = new Exception1();

public void Prova(int x)
{
int v=x;
try
{if(v==0) throw e1;
}
catch(Exception1 err)
{}
}
}

in un altra classe esiste un metodo che esegue

int z= In.readInt();
aaa.Prova(z);

Vorrei vedere da quì se è stata lanciata l'eccezione in Prova. Sottolineo che vorrei vederlo da quì!!!!

02-02-2005 14:53
Click Here to See the Profile for K)M4STER Click here to Send K)M4STER a Private Message Find more posts by K)M4STER Add K)M4STER to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
dayfallen
.consigliere.

User info:
Registered: Sep 2004
Posts: 124 (0.02 al dì)
Location: Lausanne, Svizzera
Corso: Comunicazione Digitale
Anno: Terzo Anno - Fuori Corso
Time Online: 1 Day, 6:07:45 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Re: Eccezioni Java

Originally posted by K)M4STER
Mi servirebbe un aiuto per risolvere il seguente problema,
amettiamo che un metodo o un costruttore di una certa classe se si verifica una determinata condizione lanci l'eccezione Exception1. Quello che mi servirebbe è vedere, in un altro metodo (o in un costruttore), se Excpetion1 è stata effettivamente lanciata...

Faccio un esempio per chiarire:

class Prova throws Exception1
{ Exception1 e1 = new Exception1();

public void Prova(int x)
{
int v=x;
try
{if(v==0) throw e1;
}
catch(Exception1 err)
{}
}
}

in un altra classe esiste un metodo che esegue

int z= In.readInt();
aaa.Prova(z);

Vorrei vedere da quì se è stata lanciata l'eccezione in Prova. Sottolineo che vorrei vederlo da quì!!!!

Non ti basta un try ?:?

05-02-2005 11:47
Click Here to See the Profile for dayfallen Click Here to See the Blog of dayfallen Click here to Send dayfallen a Private Message Find more posts by dayfallen Add dayfallen to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
K)M4STER
.precettore.

User info:
Registered: Nov 2004
Posts: 96 (0.01 al dì)
Location:
Corso:
Anno:
Time Online: 1 Day, 0:40:10 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

eh no, perchè il catch di Prova vede l'eccezione... Se facessi un try anche sotto non trova nessuna eccezione!

05-02-2005 12:18
Click Here to See the Profile for K)M4STER Click here to Send K)M4STER a Private Message Find more posts by K)M4STER Add K)M4STER to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
nous
.:Retore Pomposo:.

User info:
Registered: Dec 2001
Posts: 2945 (0.34 al dì)
Location: Fino Mornasco - Como
Corso: Informatica
Anno: Specialista
Time Online: 16 Days, 13:56:49 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

public bool Prova(int x)
{
int v=x;
try
{
if(v==0) throw e1;
}
catch(Exception1 err)
{
return false;
}
return true
}

E poi :

if !aaa.Prova(z) {Ho l'eccezione}
else {non ho l'eccezione}


P.s. il tuo metodo di esempio era chiamato come il costruttore della classe per errore (e quindi devi cambiare il nome del metodo, ma il mio sistema funziona) o perchè è un costruttore (e quindi devi togliere il valore di ritorno, e il mio metodo non funziona)?

__________________
Cristian,il Nous che invoglia ^_^

"La capa è troppo in la,e la sbarba è troppo giovane..mi sa che qua si va in bianco"
Ryo Saeba (City Hunter)

Last edited by nous on 07-02-2005 at 08:04

07-02-2005 08:02
Click Here to See the Profile for nous Click Here to See the Blog of nous Click here to Send nous a Private Message Visit nous's homepage! Find more posts by nous Add nous to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
ToBlEr:OnE
.arcimaestro.

User info:
Registered: Apr 2003
Posts: 264 (0.03 al dì)
Location: Cusano M. (MI)
Corso: Comunicatio Digitalis
Anno: TRE(sh)
Time Online: 1 Day, 23:07:14 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Ragazzi ho una cosa da chiedervi riguardo le eccezioni, in particolare NoMoreCard e InvalidCard.
Se devo essere sincero io non so cosa inserire nel corpo della classe eccezione. Non posso mettere un semplice return del tipo "Carta non valida!" e poi lo richiamo nei costruttori carta, mazzo, mano eccetera?
Tipo se inserisco una carta che non esiste (esempio -3) gli faccio lanciare l'eccezione di cui sopra.
Che ne dite? Ho fatto ancora più casini? Grazie mille in anticipo.

__________________
Blow[mono/CASUAL]*lab®

http://www.tobler.tk

07-02-2005 14:09
Click Here to See the Profile for ToBlEr:OnE Click here to Send ToBlEr:OnE a Private Message Visit ToBlEr:OnE's homepage! Find more posts by ToBlEr:OnE Add ToBlEr:OnE to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
K)M4STER
.precettore.

User info:
Registered: Nov 2004
Posts: 96 (0.01 al dì)
Location:
Corso:
Anno:
Time Online: 1 Day, 0:40:10 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Fermo fermo, le classi che identificano le eccezioni non devono ritornare un bel niente!!! Io le ho lasciate vuote!

07-02-2005 16:58
Click Here to See the Profile for K)M4STER Click here to Send K)M4STER a Private Message Find more posts by K)M4STER Add K)M4STER to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
ToBlEr:OnE
.arcimaestro.

User info:
Registered: Apr 2003
Posts: 264 (0.03 al dì)
Location: Cusano M. (MI)
Corso: Comunicatio Digitalis
Anno: TRE(sh)
Time Online: 1 Day, 23:07:14 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by K)M4STER
Fermo fermo, le classi che identificano le eccezioni non devono ritornare un bel niente!!! Io le ho lasciate vuote!


tu vuoi dirmi che hai esteso Exception e dentro nulla? Nemmeno un costruttore?

__________________
Blow[mono/CASUAL]*lab®

http://www.tobler.tk

07-02-2005 17:41
Click Here to See the Profile for ToBlEr:OnE Click here to Send ToBlEr:OnE a Private Message Visit ToBlEr:OnE's homepage! Find more posts by ToBlEr:OnE Add ToBlEr:OnE to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
K)M4STER
.precettore.

User info:
Registered: Nov 2004
Posts: 96 (0.01 al dì)
Location:
Corso:
Anno:
Time Online: 1 Day, 0:40:10 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Certo il costruttore è da mettere, altrimenti da errore, ma all'interno non ho scritto nulla...

08-02-2005 11:33
Click Here to See the Profile for K)M4STER Click here to Send K)M4STER a Private Message Find more posts by K)M4STER Add K)M4STER to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 20:16.    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.057 seconds (56.59% PHP - 43.41% MySQL) con 26 query.