Results 1 to 4 of 4
Thread: playing card notation
- 02-22-2011, 03:36 PM #1
Senior Member
- Join Date
- Feb 2011
- Posts
- 231
- Rep Power
- 3
playing card notation
how would i get a 10 in there, since it could only be a character? i see that you could print the 10 out automatically since there are three characters instead of two. would that be the only way to do this?Java Code:if (cardName.length() == 3) { card = cardName.charAt(0); switch (card) { case 'A': case 'a': cardName = "Ace"; break; case 'J': case 'b': cardName = "Jack"; break; case 'K': case 'k': cardName = "King"; break; case 'Q': case 'q': cardName = "Queen"; break; case '2': cardName = "Card 2"; break; case '3': cardName = "Card 3"; break; case '4': cardName = "Card 4"; break; case '5': cardName = "Card 5"; break; case '6': cardName = "Card 6"; break; case '7': cardName = "Card 7"; break; case '8': cardName = "Card 8"; break; case '9': cardName = "Card 9"; break; default: cardName = ""; break; }Last edited by droidus; 02-22-2011 at 04:14 PM.
- 02-22-2011, 04:23 PM #2
Senior Member
- Join Date
- Feb 2010
- Location
- Waterford, Ireland
- Posts
- 748
- Rep Power
- 4
Enums could be useful
Enums
- 02-22-2011, 05:42 PM #3
Senior Member
- Join Date
- Nov 2010
- Posts
- 210
- Rep Power
- 3
Alternatively, you could use a 2-digit hex, where the first digit is the suit and the second is the rank. Enums would probably be considered better practice though.
Edit: If you want to use a char, you could use 'T' for 10. That's the notation that most poker software uses when displaying text to the player.Last edited by Iron Lion; 02-22-2011 at 05:44 PM.
- 02-23-2011, 12:54 AM #4
Senior Member
- Join Date
- Mar 2010
- Posts
- 953
- Rep Power
- 4
Similar Threads
-
Big O notation
By simorgh in forum Advanced JavaReplies: 18Last Post: 07-10-2010, 03:26 PM -
Question Card Layout, Card Management
By lrichil in forum AWT / SwingReplies: 1Last Post: 04-22-2010, 10:11 AM -
Big O notation
By vendetta in forum New To JavaReplies: 6Last Post: 01-08-2010, 07:47 PM -
Big O Notation
By dsym@comcast.net in forum New To JavaReplies: 1Last Post: 02-21-2009, 06:02 PM -
Postfix-Notation
By little_polarbear in forum New To JavaReplies: 9Last Post: 09-09-2008, 04:24 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks