James Mousseau

Greenhorn
+ Follow
since May 28, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by James Mousseau



Its supposed to set the Jlabel to 1, then when the game starts again, how do I keep it counting from 1 on?
it seems to stay at 1.



Is declared in the public class XOXO, and this is the restart to the game under public static void:


Last time I had a problem like this it was where the variables were defined, but Im pretty sure they are where they are supposed to do...

last think I promise
[ June 11, 2008: Message edited by: James Mousseau ]
16 years ago
I Honestly think that solved my whole problem.

It works for box1,2, and 3!

I honestly dont know how to thank you gregg.

Ill try to finish up the program, dont think with that information there, its smooth sailing

Thanks again!


EDIT:

And yes, it did clear it up Ed, Much appreciated for all the help I recieved since I joined.

Ill try to give back to the community in a few years when I start learning more and more about Computer Programming.

[ June 11, 2008: Message edited by: James Mousseau ]
16 years ago


What im trying to say is:

If box1's text is "X", and box2's text is "X", and box3's text is "X"

then output X Wins in a label,

else
leave it at Get 3 in a row.

Because my code sends the text to the buttons on X or O, so if there is 3 in a row that way, then output a winner.

If that makes sense, and I noticed you typed different methods on doing that possibly, which one would I like to use in this sort of format
[ June 11, 2008: Message edited by: Ulf Dittmer ]
16 years ago
I just added that in, same problem, but didnt add the void part

I was wondering if this would make the difference


and I see you set play as char, so would that make a difference? or no?
16 years ago
Im not too sure where you program, but It didnt seem to want to run in "Ready To Program", which is what I use.

Couldnt see it run, so im still a little bit confused on the mathematics...

I tried piecing a bit of your code in for the mathematics in the private void, and it still wouldnt work properly, it would output the winner, even though the winner didnt win.

I do appreciate the help, I was just wondering with my code if you see a slight difference from yours, because mixing two different program styles usually doesnt work. Yours involves more complexity, compared to my basic coding. (eg, I have it rigged up so if you expand the program it wont look anything like X and O game, you have to keep it as it lies)

Im looking at your code, and I seen some things that I havent "understood" yet.

Im still continuing to fool around with it, but it seems to always get worse... and Im not too sure on why...



The thing I dont understand is could the problem be because of the placement of brackets? or the fact that I need more of something (missing something)?

Thats all the buttons, all the commands on the math, and functioning of the program from where I am now (not many changes, but some).

Hopefully a thank you in advance


EDIT:
And I was wondering if this could be an alternate ending to this massacre:

But the thing is I get an error saying its not boolean or something for the line "if (box1.setText = "X" && box2.setText ("X") && box3.setText("X"))"
Is there a way to set it up that way, or is it undoable?
[ June 11, 2008: Message edited by: James Mousseau ]
16 years ago
Well, it seems to work now, but its the same problem. It only switches up in box9

EDIT:
Could it be the placement on where the cols/rows/diags are placed, what if they are placed in lets say the code where box1 code is for X or O?

Or if it should be placed inside a bracket differently...

Im about ready to get the hammer!
[ June 10, 2008: Message edited by: James Mousseau ]
16 years ago
Tricky situation, it does not seem to want to work for me...

Error sais that "The type of the right sub-expression "java.lang.String", is not assignable to the variable, of type "char""

So I was wondering if I wrote it wrong, because I cant seem to figure out on where to assign the char to the clicks of X's and O's otherwise.



16 years ago
Makes perfect sense, thanks again.
16 years ago

Originally posted by Gregg Bolinger:
Ok, so here is what I would do. At least something like this.

Create a matrix to hold your x's and o's

char matrix[][] = new char[3][3];

When a button is clicked determine which position in the matrix to update:

matrix[2][1] = "X";

After which, you check the rows, cols, and diags:



This is extremely helpful, but the thing I dont get is "char matrix[][] = new char[3][3];"

When you have the [3][3], what does that mean, im a little unsure of this, is that basically saying 3X3? And for the rows, columns, and diagonals, how does that register 3 across, up and down, and top side to bottom opposite?

And before you go any further, I would really like to thank you and the site for being so helpful, I really appreciate all the help you and the JavaRanch community has done for me.
16 years ago
Yes sir, it is a game.


I programmed this code looking at stuff on the internet, kinda new, but I have some knowledge of programming, just not much. its the mathematics left in the program that I must finish, and it doesnt seem to want to work out for me.

And I really appreciate you taking time to review this for me.
[ June 11, 2008: Message edited by: Ulf Dittmer ]
16 years ago
I have the code entered when something is clicked, do this, but I cant seem to find out how to make it if 3 of them are clicked and marked as something, then do this.

I can upload all of the code, but it doesn't seem necessary. I cant seem to find the logic in saying if 3 of the 9 buttons are the same output ("X"), then do something else.
16 years ago
How can you say "If this button is clicked, and this button is clicked, and this button is clicked, Do this"

The thing is They have to be clicked within a certain order.

if (("X".equals (box1))&& ("X".equals (box2)) && ("X".equals (box3)))

winner is a Jlabel; box1 - box9 are buttons; p1s = int; PO = TextField; score1 is a string.
and Im unsure on how to get the int p1s to convert it to a string so it can be outputted in the PO textbox.

I would really appreciate the help
16 years ago
I really appreciate all of the help guys, its really helping me get my brain ready for college.

Ill try both methods out, so I know both

Much appreciated!
16 years ago
kind of, I now know that their placement is off, and that makes sence since it seems to repeat the step of adding 2 to p1turn, and it always gets resetted and repeating step 1, Ill try that out...

I think you saved me hours of struggle

Thanks a bunch!

EDIT:

It works like a charm!!!
[ June 06, 2008: Message edited by: James Mousseau ]
16 years ago
Thanks for those links to other posts, and the advice on shortening my code, ill try it out, thanks
16 years ago