aspose file tools*
The moose likes Java in General and the fly likes multiplayer rock paper scissors code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "multiplayer rock paper scissors code" Watch "multiplayer rock paper scissors code" New topic
Author

multiplayer rock paper scissors code

ameya disuja
Greenhorn

Joined: Apr 23, 2012
Posts: 2
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

Joined: Dec 07, 2006
Posts: 208
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

Joined: Apr 23, 2012
Posts: 2
can you please explain in details ?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
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

Joined: Dec 07, 2006
Posts: 208
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

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: multiplayer rock paper scissors code