•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 455,985 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,760 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 340 | Replies: 2 | Solved
![]() |
•
•
Join Date: Aug 2007
Location: Cherryville, NC
Posts: 34
Reputation:
Rep Power: 2
Solved Threads: 0
can anybody see anything worng?
I'm returning these to the main
sO=ScoreO(O);
sX=ScoreX(X);
These are my two methods:
[java]
//method to tally the score for x
public static int ScoreX(boolean X){
int scoreX=0;
if(X==true){
scoreX+=1;
}
return scoreX;
}
//method to tally the score for x
public static int ScoreO(boolean O){
int scoreO=0;
if (O== true){
scoreO+=1;
}
return scoreO;
}
}
[/java]
What is wrong, because I can't figure it out...
I'm returning these to the main
sO=ScoreO(O);
sX=ScoreX(X);
These are my two methods:
[java]
//method to tally the score for x
public static int ScoreX(boolean X){
int scoreX=0;
if(X==true){
scoreX+=1;
}
return scoreX;
}
//method to tally the score for x
public static int ScoreO(boolean O){
int scoreO=0;
if (O== true){
scoreO+=1;
}
return scoreO;
}
}
[/java]
What is wrong, because I can't figure it out...
Last edited by Dio1080 : Dec 4th, 2007 at 1:00 am. Reason: BB code wont work
It might help to know what you expect, and what you get, as well as any errors that are occurring. But, thing, if you are passing a boolean already then the == is redundant. Simply do
if (O) { Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- calling a graphics method (Java)
- Got Fractions? Method help w/ logic issue (Java)
- Cannot incorporate equals method for a yes or no answer. (Java)
- JTextField not getting updated when using setText(String) method (Java)
- Best method to add new Hard drive and re-install Windows Xp? (Windows NT / 2000 / XP / 2003)
- Java Applet viewer blinks everytime the init method is used. (Java)
- Cannot get method in project to work (Java)
- Multipointer Manipulating System and Method (Computer Science and Software Design)
Other Threads in the Java Forum
- Previous Thread: Random Salary
- Next Thread: generics in java



Linear Mode