wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Simple logic is kicking my butt. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Simple logic is kicking my butt." Watch "Simple logic is kicking my butt." New topic
Author

Simple logic is kicking my butt.

Robert Brown
Greenhorn

Joined: Apr 02, 2009
Posts: 4
im having a problem here and it seems I just cannot get my logic right.

this is in a class



and this is what is in my driver


no matter what it will not get past the first if statement and returns my "invalid input" error. What did I do wrong thanks for any help
Paul Yule
Ranch Hand

Joined: May 12, 2008
Posts: 229
um. Don't hit yourself too hard but lets pretend that you input 'O' ... the first OR in your if statement will evaluate to true and kick you down. I think you mean to have used
( ch != 'X' && ch != 'x' && ch != 'O' && ch != 'o')... if it isn't ANY of those...go in there. Not if it isn't just one of those cases.
Robert Brown
Greenhorn

Joined: Apr 02, 2009
Posts: 4
Thank you very much. I knew it was something too simple, can't believe I missed that; Moral of the story.... caffeine != a substitute for sleep.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
Welcome to JavaRanch

Putting !() round your test would sort it out. You can use different formulae; look up de Morgan's Law for how to convert between || and && when there are nots around.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple logic is kicking my butt.
 
Similar Threads
TicTacToe! Stop user from changing input
TicTacToe Game..
Game Tutorials -->> TicTacToe
TicTacToe game
TicTacToe Game