Results 21 to 21 of 21
- 08-14-2012, 10:18 PM #21
Re: High-Low Game
Well... from what I read, you should start off small. If you have not learned about gathering User input from the Standard In/Out, then you must be really new to this. Forget about the graphics for a while. That will only make things even more complicated.
Now, your interface will look something like this:
The card is: 8 of spades.
Is the following number higher or lower than this one?
type 'h' for high or 'l' for low: [ get input ]
That interface only requires System.out.println(); and that is it.
After that, you should include some code that calculates what happens after that. Before you generate Random Numbers, you should just hard code a number and run test off of that number first and see if it works. For example: the number presented is 3. The next card will always be 5. if you enter 'h', you win. if not, you lose. Then, just play with the values and make sure your code works. After that point you will want to learn how to generate Random Numbers in Java. A Google search will help with that.
To get user input, all you need is:
Scanner in = new Scanner(System.in); String userChoice = in.next();
This should be a good start. If you cannot formulate some code with what I have provided you, then you should take a look at the Oracle tutorial: Lesson: Language Basics (The Java™ Tutorials > Learning the Java Language). Do some examples, become versed in the basics of Java, then create some code. After that tutorial, you should not need to ask us for any help with your program, but if you do come back to us with a problem if one comes up. Make sure to provide you current solution, what is going wrong (glitches), any errors that manifest themselves, and any sample code you might have.
Hope this helps!!!My API:Java Code:
cat > a.out || cat > main.class
- By xcaldk74 in forum New To JavaReplies: 12Last Post: 02-29-2012, 09:38 PM
- By zlass in forum New To JavaReplies: 2Last Post: 12-03-2011, 09:51 PM
- By farzana shamim in forum Forum LobbyReplies: 1Last Post: 07-22-2009, 02:43 PM
- By pouria62 in forum AWT / SwingReplies: 1Last Post: 10-26-2008, 01:57 PM
- By Sarinam in forum NetworkingReplies: 2Last Post: 06-16-2008, 02:38 PM