Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Pocetnicki problem, help....

[es] :: Java :: Pocetnicki problem, help....

Strane: 1 2

[ Pregleda: 7306 | Odgovora: 26 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

anon81183

Član broj: 81183
Poruke: 117
*.beotel.net.



Profil

icon Re: Pocetnicki problem, help....18.10.2006. u 18:00 - pre 212 meseci
setih se "C-a"

IF ( q == 1)
 
Odgovor na temu

nemnesic
nemnesic
Software Developer
Vranje Florida

Moderator
Član broj: 44355
Poruke: 802
*.com
Via: [es] mailing liste



+64 Profil

icon Re: Pocetnicki problem, help....18.10.2006. u 18:04 - pre 212 meseci
za uporedjivanje moras da koristis ==,<=,>=, != ti je za assign value to a variable ( kako se bre kaza ovo na nasem
jeziku)?


nn
 
Odgovor na temu

lukeguy
Novi Sad

Član broj: 46545
Poruke: 470
*.net
Via: [es] mailing liste



+8 Profil

icon Re: Pocetnicki problem, help....20.10.2006. u 20:41 - pre 212 meseci
Da li samo moj kompajler javlja grešku o neuhvaćenom izuzetku ili ovde stvarno fali try..catch blok oko Integer.parseInt()?
 
Odgovor na temu

zvjerka24
Vladimir Pavlovic
Apsolvent
Novi Sad

Član broj: 62788
Poruke: 15
*.ns.ac.yu.

Sajt: www.VPavlovic.cjb.net


Profil

icon Re: Pocetnicki problem, help....20.10.2006. u 23:08 - pre 212 meseci
Metoda parseInt() iz klase Integer može da vrati izuzetak ukoliko ne može da parsira proslijeđeni String. U suštini, za sve stvari koristiti Javinu dokumentaciju, a ako pogledaš specifikaciju ove metode, vidjećeš da baca izuzetak NumberFormatExceptionParses (if the string does not contain a parsable integer.). Evo šta piše u dokumentaciji"



public static int parseInt(String s) throws NumberFormatExceptionParses

the string argument as a signed decimal integer. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('\u002D') to indicate a negative value. The resulting integer value is returned, exactly as if the argument and the radix 10 were given as arguments to the parseInt(java.lang.String, int) method.

Parameters:
s - a String containing the int representation to be parsed
Returns:
the integer value represented by the argument in decimal.
Throws:
NumberFormatException - if the string does not contain a parsable integer.
Zvjerka was here!
 
Odgovor na temu

anon81183

Član broj: 81183
Poruke: 117
195.252.90.*



Profil

icon Re: Pocetnicki problem, help....22.10.2006. u 18:46 - pre 212 meseci
Evo mene sa novim porblemom : D
poceo sam praviti malu igru (RPG)

Imam dva fajla

Prvi "code.java"

Code:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class code {

   

        public static void main(String []args)throws IOException{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            // ubacivanje funkcije rese
            karakter por;
            por = new karakter();
        System.out.println("Ime: ");
        String ime = br.readLine().trim();
        System.out.println("Odaberi rasu:\n Aranos (1)\n Mordus(2)\n Kharanos(3)\n ");
        por.igrac();
               
   }        
    
   }


a drugi se zove "karakter.java"

Code:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class karakter {

void igrac (String []args)throws IOException{ {
    // sposobnosti
    char ime;
    int upl,ube,ukr;
    int kljuc=0, prsten=0;
    int nacija;
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String a = br.readLine().trim();
    int ras = Integer.parseInt(a);
   
        if (ras == 1){
          ras = 1;        
        }            
        if (ras == 2){
        ras = 2;            
        }            
        if (ras == 3){
        ras = 3;        
        }       
            
    nacija = ras;
            
    
    if (nacija == 1)
    {
     upl = 0;
     ube = 5;
     ukr = 1;    
    }
    
        if  (nacija == 2)
        {
        upl = 5;
         ube = 0;
         ukr = 1;
        }
    
            if (nacija == 3)
            {
            upl = 1;
             ube = 2;
             ukr = 4;    
            }
}
}
    
}



zasto pravi gresu u redu "por.igrac();" u prvom fajlu??
 
Odgovor na temu

sasa_vu
Beograd

Član broj: 62061
Poruke: 200

Sajt: www.fuckoffimbusy.com


+53 Profil

icon Re: Pocetnicki problem, help....22.10.2006. u 21:11 - pre 212 meseci
Brzinski odgovor dok ne pocne drugo poluvreme utakmice:-)
Metod igrac prima argumente u klasi karakter, a u klasi gde ga pozivas ne prosledjujes mu te argumente, zato ti prijavljuje gresku. Ispada da pozivas metod koji ne postoji. Znaci ili mu prosledi neke argumente, ili drugacije napravi metod ako ti argumenti ne trebaju.
por.igrac() i igrac(String []args), nadam se da je sada jasnije.
Mali hint, imena klasa pisi velikim slovom.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
 
Odgovor na temu

lukeguy
Novi Sad

Član broj: 46545
Poruke: 470
*.net
Via: [es] mailing liste



+8 Profil

icon Re: Pocetnicki problem, help....25.10.2006. u 09:19 - pre 212 meseci
Što znači da u gornjem kodu nedostaje try..catch? Kako je onda uopšte mogao da se iskompajlira? Kod mene odbija, kaže da izuzetak nije uhvaćen ili da u deklaraciji metode dodam ključnu reč "throws".
 
Odgovor na temu

[es] :: Java :: Pocetnicki problem, help....

Strane: 1 2

[ Pregleda: 7306 | Odgovora: 26 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.