This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes help in tic tac toe program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "help in tic tac toe program" Watch "help in tic tac toe program" New topic
Author

help in tic tac toe program

ten doeschate
Greenhorn

Joined: Jun 22, 2013
Posts: 16
in the attached file

i have problem with the percentage_games and percentage_games1 variable
it is not updating correctly as when both X and O have 1won 1 game each it should show percentage as 50 but it is showing 100 and 0

please help!!

my program is as follows:



Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

Welcome to the Ranch!

Keep in mind that the division operator denotes integer division if both operands are integers, and floating-point division otherwise. Yours is the first case - both of your operands are integers (e.g. 1/2 = 0 by integer division), hence the results you get.


The quieter you are, the more you are able to hear.
Piet Souris
Ranch Hand

Joined: Mar 08, 2009
Posts: 533
    
    8
check your lines 265 and 266. It has to do with integer division.

Greetings,
Piet
ten doeschate
Greenhorn

Joined: Jun 22, 2013
Posts: 16
can yu help me how to use showStatus() in above program by extending JApplet

it is showing error as NullPointer Exception

please help
Piet Souris
Ranch Hand

Joined: Mar 08, 2009
Posts: 533
    
    8
I can't find a "showStatus()" method in your code.

And, is it your intention to run "TicTacToe" as an applet?

A remark: you are using expressions like "if (letter == "X") {...}".
Since you are using string literals here, you might get away with this. But you should always use "if (letter.equals(someOtherString)) {...}".
 
wood burning stoves
 
subject: help in tic tac toe program