Results 1 to 8 of 8
  1. #1
    flagrl is offline Member
    Join Date
    Jan 2012
    Posts
    12
    Rep Power
    0

    Default need some advice

    Im making the rock paper scissors program. it has to have different methods. haven't got that far but have a few questions. I am making a showoption dialog box and I have done that successfully. but for some reason my mind has went blank. what do I do after that? do I use the if else statments? I don't want the code wrote for me I just seem to be having a mind fart. what would I put into different methods? any advice would be wonderful because I am stuck

  2. #2
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    364
    Rep Power
    5

    Default Re: need some advice

    I guess it depends. Are you trying to make a game where 1 person plays with the program?

  3. #3
    flagrl is offline Member
    Join Date
    Jan 2012
    Posts
    12
    Rep Power
    0

    Default Re: need some advice

    sorry should have been more specific. yes 1 person plays against the computer. the computer chooses first then the player choooses, w/o seeing the computer's choice

  4. #4
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    364
    Rep Power
    5

    Default Re: need some advice

    Ok. As far as the implementation of the game, you could do it several ways. A dialog box is a good start. Maybe think about creating a custom dialog that has a JComboBox with 3 choices (rock,paper,scissors) and a Submit (whatever you want to call it, go, play, etc) button.

    As far as making the computer selection, I would probably have a HashMap<Integer, String> that maps 1 to rock, 2 to paper, and 3 to scissors. Then you could have a Random Number Generator that is bound from 1-3, and based on the number returned, get the value that it corresponds to in your map. That would be a good way to get the computers selection randomly, even though with only 3 choices a RNG may be overkill, but I'm not sure if there are better ways.

    That's a starting point. Then maybe come up with a way to map each item to the item that it beats. The rest of it is presentation for the most part.

  5. #5
    flagrl is offline Member
    Join Date
    Jan 2012
    Posts
    12
    Rep Power
    0

    Default Re: need some advice

    I made a dialog box that had 4 choices, rock, paper, scissors, and quit in a showoption dialog box, I think that's what its called, is that basically the same thing? I will work on your other suggestions and see what I come up with. thank you

  6. #6
    flagrl is offline Member
    Join Date
    Jan 2012
    Posts
    12
    Rep Power
    0

    Default Re: need some advice

    how would I assign a variable to the boxes on the JOptioinpane box. here is what I got so far its not much,
    code:private static Component frame;
    public static void main(String[] args) {

    Java Code:
    JOptionPane.showMessageDialog(null, "Welcome to the game Rock, Paper, Scissors:");
            String rock;
            String paper;
            String scissors;
           String comp = "";   
      
     {
     Object[] Game = {"rock",
                        "paper",
                        "scissors", "quit"};
          JOptionPane.showOptionDialog(
                  frame,
                "choose one option below: ",
                "Options ",
                JOptionPane.DEFAULT_OPTION,
                JOptionPane.QUESTION_MESSAGE,
                null,
                Game,
                Game[2]);

  7. #7
    subzero1012 is offline Member
    Join Date
    Feb 2012
    Location
    Phoenix, AZ
    Posts
    26
    Rep Power
    0

    Default Re: need some advice

    Could you please repost the entire formatted code? Thanks.

  8. #8
    flagrl is offline Member
    Join Date
    Jan 2012
    Posts
    12
    Rep Power
    0

    Default Re: need some advice

    thats it. i have nothing so far. i started with the JOptionpane dialog box because we hadnt gone over that kind so i would start with it first. so that is all i got. told you it isnt much :)

Similar Threads

  1. advice
    By icedust in forum Advanced Java
    Replies: 1
    Last Post: 10-11-2011, 12:50 AM
  2. Want an advice
    By baf06 in forum New To Java
    Replies: 3
    Last Post: 04-17-2011, 07:39 AM
  3. Need some serious advice
    By Rituparna in forum Jobs Discussion
    Replies: 6
    Last Post: 03-25-2011, 07:34 PM
  4. got any advice?
    By cejay in forum Networking
    Replies: 2
    Last Post: 03-17-2011, 11:33 AM
  5. Im new n looking for an advice
    By azlynn in forum New To Java
    Replies: 2
    Last Post: 12-10-2009, 03:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •