Results 1 to 2 of 2
Thread: Card Game
- 07-24-2010, 12:46 AM #1
Member
- Join Date
- Jul 2010
- Posts
- 10
- Rep Power
- 0
Card Game
Hi I am trying to make a Card game where there are 2 inputs and it decides who is the winner.. But what I am having problem with is taking an input as A or J or Q or K and assigning their respective values i.e. 14, 11,1 2, 13.. If anybody could help it would be great.
Java Code:package cardGame; import javax.swing.*; public class cardGame { public static void main (String args[]){ int card1; int card2; String input; input = JOptionPane.showInputDialog("Enter first Card: "); card1 = Integer.parseInt(input); input = JOptionPane.showInputDialog("Enter second Card: "); card2 = Integer.parseInt(input); if (card1 == card2){ //Checks if 2 cards are equal JOptionPane.showMessageDialog(null, "It's a Tie"); return; } double large; large = Math.max(card1,card2); if (card1 == large){//Checks the winner JOptionPane.showMessageDialog(null, "First Player Wins"); } else if (card2 == large){ JOptionPane.showMessageDialog(null, "Second Player Wins"); } } }
- 07-24-2010, 01:38 AM #2
Similar Threads
-
please help me with this card game
By noobinoo in forum New To JavaReplies: 13Last Post: 03-28-2010, 03:07 PM -
4x4 2D array card game,need solving
By highschool in forum New To JavaReplies: 6Last Post: 02-25-2010, 04:36 PM -
Creating a Card Game in Java
By Natrix in forum New To JavaReplies: 1Last Post: 05-05-2009, 06:55 PM -
card game Rummy
By javafox in forum New To JavaReplies: 4Last Post: 03-14-2009, 04:53 PM -
A Online Card Game
By GonzaloP in forum NetworkingReplies: 0Last Post: 12-28-2008, 07:37 PM
Bookmarks