Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

multiplayer rock paper scissors code

 
ameya disuja
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a code for rock paper scissors game , but this is only single player game and i want to develop it for multilayer
can any one help me for that logic?

my single player game code is






kindly help me for that.....
 
Niall Loughnane
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

An idea,

You could:
- refactor the code and store the session information variables in a Data Transfer Object (DTO)
- when the game starts running, ask the user initially how many players there are playing
- store the number of players in a Map
- run through the Map for each user and let the user have fun playing the game

Hope it helps,

Niall
 
ameya disuja
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please explain in details ?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49789
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I think you ought to use an enum for the game. Not only can you say == ROCK, but you can also have loses to paper and wins over scissors in that object. There is a lot of non-object-oriented code in that main method. You should have a Player class with scores as a field. Please search; similar problems come up reasonably frequently.
 
Niall Loughnane
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

a good description on Data Transfer Objects (DTOS) can be found here:
http://www.southsearepublic.org/article/2157/read/data_transfer_objects_value_objects_and_domain_models_in_j2ee

Hope the link helps,

Niall

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic