Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Need help with Rock paper Scissors code ASAP

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Andrew Erdman
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I might be missing a part of the end code for the wins or something. And I think it is in a loop because when you type rock or whatever it does not run. Any help is appreciated, thank you
 
Marshal
Posts: 15629
264
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Folks don't really respond to "ASAP" and "URGENT" messages, so you might as well EaseUp, pardner. We'll git to ya when we git to ya.
 
Junilu Lacar
Marshal
Posts: 15629
264
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure you know what all the possible values that this line of code will assign to num2?

Maybe you should try to see for sure what all values num2 will get from this.
 
Junilu Lacar
Marshal
Posts: 15629
264
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, look carefully at line 24:

If you're using an IDE like Eclipse or NetBeans and you used the keyboard shortcut Ctrl+Shift+F to format your code, it would have been more apparent. As it is now, that little bug is hiding at the end of the line.
 
Junilu Lacar
Marshal
Posts: 15629
264
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what exactly is it you think you're trying to do on lines 71-82? It looks like you are checking for a bunch of different condition but you're printing out the same message regardless. That doesn't seem logical.
 
Junilu Lacar
Marshal
Posts: 15629
264
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check your prompt on line 21: you don't give an option for paper but you have two options for rock.

Here's a neat trick:

If you assign Rock=1, Paper=2, Scissors=3

Let:
p1 be the move player 1 makes
p2 be the move player 2 makes

Then:
result = (p1 - p2 + 3) % 3

0 -> tie
1 -> player 1 wins
2 -> player 2 wins
 
Whose rules are you playing by? This tiny ad doesn't respect those rules:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic