• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Can someone please be bothered to try this, thanks Rock paper scissors

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
'paper, scissors, rock' with a user. A game consists of a user-defined number of rounds.
A single round of the game works as follows:
The user and the program each choose a number: 0 (for 'paper'), 1 (for 'scissors') or 2 (for 'rock'). The program uses a random number generator to make its choice. The result of the round is as follows:
Enter 0, 1 or 2 for paper, scissors, rock
1
My choice was 2
Rock blunts scissors: I win
Your Game class should contain:
a public integer instance variable called numRounds, that records how many
rounds of the game have been played.
a public integer instance variable called roundsWon, that records how many
rounds of the game have been won by the human player.
a public void method called playGame(), which plays the game
Method playGame() should ask the user how many rounds to play, and then play that many rounds of the game. Variables numRounds and roundsWon should be correctly updated by the method.

 
Sheriff
Posts: 7113
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch, Ross.

It looks like you've posted your homework assignment. We're happy to help you but you have to ShowSomeEffort (← click me). Show us either what you have already coded or post an outline of what you think the program should do.
 
Marshal
Posts: 17010
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had to complete a similar project in an online Python class I took at Coursera.com except we had to do the more geeky RPSLS (Rock, Paper, Scissors, Lizard, Spock). What do you have so far?
 
Marshal
Posts: 8303
592
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ross Born,

If I understand, you have to write two programs, server and a client, and they have to communicate through a TCP protocol. Correct?
 
Liutauras Vilda
Marshal
Posts: 8303
592
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, some hints if my guess is correct in a top post.

On a program (server) side, you'll have to use likely these classes:
BufferedReader, BufferedWriter, InputStreamReader, OutputStreamWriter, ServerSocket, Socket
1. Very first step likely will be on your program to create a server socket object and wait for connection on specific port (if it is not provided, then pick some you like).

On a user (client) side:
BufferedReader, BufferedWriter, InputStreamReader, OutputStreamWriter, Socket
1. On client - create a socket by specifying your local machine host address and port you want to connect (on server and client they have to match).

The rest of flow are pretty clear described in english, what has to be done.
Ross, do you have any specific questions about your assignment, which you cannot understand?

Probably mostly of the guys would suggest you still to start with a pencil and the paper, it would save some your time later, if you'd get lost.


 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see anything in the OP that implies a client/server architecture.
Looks like a simple console based game.
 
Liutauras Vilda
Marshal
Posts: 8303
592
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:I don't see anything in the OP that implies a client/server architecture.
Looks like a simple console based game.


I might overcomplicated, not sure, you might right.
Well, then everything is easier.
 
reply
    Bookmark Topic Watch Topic
  • New Topic