• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple logic is kicking my butt.

 
Robert Brown
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic