The Artima Developer Community
Sponsored Link

Java Answers Forum
help!

1 reply on 1 page. Most recent reply: May 7, 2003 11:40 AM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
jess

Posts: 1
Nickname: jess88
Registered: May, 2003

help! Posted: May 7, 2003 7:38 AM
Reply to this message Reply
Advertisement
can anyone help me on my coding?
i've problem when i load the boolean type smoker, setSmk(smoker) will give me error cos my setter should pass in a boolean type
i'm new in java n not familiar with files. hope someone can help me, thanks!
public boolean readRec(BufferedReader patFile)throws IOException{
boolean morePat = true;
String inString = "";
int inAge = 0;
int weight = 0;

inString = patFile.readLine();
if(inString!=null){
try{
setId(inString);
inString = patFile.readLine();
setName(inString);
inString = patFile.readLine();
inAge = Integer.parseInt(inString);
setAge(inAge);
inString = patFile.readLine();
weight = Integer.parseInt(inString);
setWgt(weight);
inString = patFile.readLine();
String smoker = String.valueOf(inString);
setSmk(smoker);

}catch(NumberFormatException ie){ System.out.println("Error during read from file"); }
}
else{
morePat = false;
}
return morePat;
}


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: help! Posted: May 7, 2003 11:40 AM
Reply to this message Reply
change the line from:

setSmk(smoker);

to
           if (smoker.equals("true")){
               setSmk(true);
           }else{
               setSmk(false);
           }

Flat View: This topic has 1 reply on 1 page
Topic: Got part of it!  Comparator??? Please Help! Previous Topic   Next Topic Topic: 2 questions related to XP

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use