Results 1 to 8 of 8
Thread: need some advice
- 03-28-2012, 10:17 PM #1
Member
- Join Date
- Jan 2012
- Posts
- 12
- Rep Power
- 0
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
- 03-28-2012, 10:22 PM #2
Re: need some advice
I guess it depends. Are you trying to make a game where 1 person plays with the program?
- 03-28-2012, 10:23 PM #3
Member
- Join Date
- Jan 2012
- Posts
- 12
- Rep Power
- 0
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
- 03-28-2012, 10:33 PM #4
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.
- 03-28-2012, 10:46 PM #5
Member
- Join Date
- Jan 2012
- Posts
- 12
- Rep Power
- 0
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
- 03-28-2012, 11:13 PM #6
Member
- Join Date
- Jan 2012
- Posts
- 12
- Rep Power
- 0
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]);
- 03-29-2012, 01:49 AM #7
Member
- Join Date
- Feb 2012
- Location
- Phoenix, AZ
- Posts
- 26
- Rep Power
- 0
Re: need some advice
Could you please repost the entire formatted code? Thanks.
- 03-29-2012, 02:05 AM #8
Member
- Join Date
- Jan 2012
- Posts
- 12
- Rep Power
- 0
Similar Threads
-
advice
By icedust in forum Advanced JavaReplies: 1Last Post: 10-11-2011, 12:50 AM -
Want an advice
By baf06 in forum New To JavaReplies: 3Last Post: 04-17-2011, 07:39 AM -
Need some serious advice
By Rituparna in forum Jobs DiscussionReplies: 6Last Post: 03-25-2011, 07:34 PM -
got any advice?
By cejay in forum NetworkingReplies: 2Last Post: 03-17-2011, 11:33 AM -
Im new n looking for an advice
By azlynn in forum New To JavaReplies: 2Last Post: 12-10-2009, 03:47 AM
Bookmarks