Monday, January 9, 2012

Tutorial: A Card Guessing Game in Java

by eturo


Hi guys out there! Are you playing guessing games? Today, I will show a simple Card Guessing Game applet I made using Java. You can copy the source code below and try to play the simple game.

I designed and build the simple game using Swing in Java. Here is the interface: (see the image below)

The GUI Design:





This is a single player card guessing game wherein you have to guess the Random Card shown whether it is higher or lower to your Guessed Card by clicking the Higher or Lower buttons. If your guessed is correct, then a message will appear displaying your number of tries and score. You have only three tries to guess.


The Game Proper:


How to start the Game?
By clicking the Start Game button, then the first Random Card game will appear from the box just like the image below.



How to guess the Random Card?
Now, if the first Random Card appear, then its time to give your Guess whether the Next Random Card is higher or lower to the previous Random Card. If your guessed is correct or not, then a message will prompt. (see the image below)



Here, the player clicked the Lower button, and his guessed (Card No. 8) is lower to the first Random Card (Card No. 9), it means that his guessed is correct. A message dialog box appeared. The Card No. 8, will serve as the new Random Card to guessed by the player.

Note: In Java, you can build message dialog boxes by using the JOptionPane class.

Like Us on Facebook

Related Posts Plugin for WordPress, Blogger...