[code]public class ParseTraining{
public static int getInt(){
int a=0;
try{
a=Integer.parseInt( getLine() );
} catch(NumberFormatException var){
a=0;
}
return a;
}
public static double getDouble(){
double b=0.0;
try{
b = Double.parseDouble( getLine() );
}catch(NumberFormatException var){
b=0.0;
}
return b;
}
public static float getFloat(){
float c=0.0F;
try{
c = Float.parseFloat( getLine() );
}catch(NumberFormatException var){
c=0.0F;
}
return c;
}
public static String getLine(){
String d="";
char r= getChar();
while(r != '\r'){
r = getChar();
d = d + r ;
}
return d;
}
public static char getChar(){
int r;
char k;
try{
r= System.in.read();
k=(char)r;
}catch(Exception var){
k=0;
}
return k;
}
}
[/code]
public class MethodOvTest{
public static void main(String [] args){
String [] countries={"Brazil","USA","England","Ireland","Acre","Area 51","Luanda","Bolivia","Paraguay",
"Roflland","Italy","Canada","Germany"};
String [] charges={"Drug traffic","Human traffic","Mangas traffic","Maintaining criminal networks","Pedophile content holder",
"Animal traffic","Cat traffic","Terrorism","Playing RJ Funk loud at 2AM"};
String [] description={"is in possession of powerful weapons"," have passed through policial records before","have a extremely agressive behavior",
"is extremely hazardous to society","has mental disorders"};
String [] contact={"Scotland Yard at +44-21321-32145","INTERPOL at Toll-free(1-800-INTERPOL)","Brazilian Police at 190","Rent-a-gunman hotline at 1-800-RENTGUNS","Jagunço do Coronel Epaminondas at 0XX18 9354-3221",
"Brazilian Federal Police at <Searching phone on Google..>"};
String [] rewards={"R$ 10,00 in EMTU tickets","5000 pieces of gold in Wow","Starcraft 2 Serial key","OT$ 100, changeable in Mupy, Mangas or even Cosplay costumes",
"One-way Subway ticket in São Paulo","1 point on your worst subject overall","1000 litres of products to Beetle's radiator repair",
"Free lunch","300-ml cup of mate tea on D-Mall","Unique-ticket charged with R$50"};
String [] lastseen={"at Paulista's avenue Starbucks while drinking a hot Frappucino","at Sé subway station, while boarding in Corinthians-Itaquera platform at 6PM",
"at Liberty station, with 300 pounds of Mangas","15th parade","Republic station","CPTM Acre station","School woodland"};
String [] date={"2/24/2010","3/23/2010","2/30/2003","12/24/1998","11/30/2007","Unknown"};
System.out.println("-------------------------------PERSONAL RECORD------------------------------------");
System.out.println("-------------------------------INPUT SECTOR---------------------------------------");
System.out.printf("\n\nPlease input the following data.");
System.out.println("\n\n\n\n\n\n\n\n");
System.out.println("Username: ");
String user= ParseTraining.getLine();
System.out.println("Height: ");
float height= ParseTraining.getFloat();
System.out.println("Weight: ");
float weight= ParseTraining.getFloat();
System.out.println("E-mail: ");
String email= ParseTraining.getLine();
System.out.println("Address: ");
String address= ParseTraining.getLine();
System.out.println("Country: ");
String country=ParseTraining.getLine();
System.out.println("Age: ");
int age=ParseTraining.getInt();
System.out.println("Sex(M/F): ");
char sex=ParseTraining.getChar();
System.out.println("--------------------INTERPOL ALERT-----------------------------");
System.out.println("------------------SCOTLAND YARD ALERT--------------------------");
if(height < 1.60){
System.out.println("A small criminal has been reported in "+countries[(int)Math.random()*13]+".");
}else{
System.out.println("A criminal has been reported in "+countries[(int)Math.random()*13]+".");
}
System.out.printf("\n\n\nName:%s\nHeight:%f\nSex:%s\nAge:%d\nOriginal Country:%s\n",
user,
height,
sex,
age,
country
);
System.out.printf("\n\n\n\n");
System.out.printf("%s's Charges",user);
System.out.println(user+" has been charged of "+charges[(int)(Math.random()*9)]+","+charges[(int)(Math.random()*9)]+
"and "+charges[(int)Math.random()*9]);
System.out.println("CAUTION! "+user+description[(int)(Math.random()*5)]+", "+description[(int)(Math.random()*5)]+" and "
+description[(int)(Math.random()*5)]);
System.out.println("The "+user+" last sight was on "+lastseen[(int)(Math.random()*9)]+", "+ date[(int)(Math.random()*6)]+
" .");
System.out.println("Rewards:");
System.out.printf("\n\n"+rewards[(int)(Math.random()*10)]+" and "+rewards[(int)(Math.random()*10)]);
System.out.println("Reward offered to clues that lead to the location of "+ user);
System.out.println("---------------------------CONTACT--------------------------------");
System.out.println("Send us the clues "+contact[(int)(Math.random()*6)]);
}
}
Bom, peço que não liguem para as coisas sem sentido escritas no MethodOvTest, era mais um programa pra treinar matrizes, random, dentre outros.Esse daí é só um exemplo de programa no qual ocorre o erro.Outros programas, ainda que, aparentemente grafados corretamente, tem o mesmo problema.
Vou pensar como fazer no NetBeans, pois temos de compilar, por enquanto, usando Notepad++ e prompt.
Agradeço,
Rafael