• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

multiplayer rock paper scissors code

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.....
 
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you please explain in details ?
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic