How to output suits of cards

I want to output the characters for the suits of cards
to the console.  If that is possible, how do I do it
castelloAsked:
Who is Participating?
 
Bob_EverardConnect With a Mentor Commented:
Do you mean something like this?  Very primitive, but...

public class suits {
   public static void main( String[] args ) {
      byte[] suits = { 0x03, 0x04, 0x05, 0x06 };
      char[] cards = { 'A', '2', '3', '4', '5', '6', '7', '8', '9',
                       'T', 'J', 'Q', 'K' };
      for ( int s = 0; s < suits.length; s++ ) {
         StringBuffer sb = new StringBuffer();
         for ( int c = 0; c < cards.length; c++ ) {
            sb.append( cards[ c ] + new String( suits, s, 1 ) + " ");
         } // for
         System.out.println( sb.toString() );
      } // for
   }
}
0
 
jcaldwelCommented:
Do you mean the DOS extended ASCII characters?

If so, Java is not the way to go for a DOS-dependent program.

0
 
hj2k3Commented:
codes 3, 4, 5 and 6 are hearts, diamonds, clubs and spades. the first and last might be the other way round, because on DOS if you press ctrl D it equates to ascii 4, but ctrl-c has a special function and crtl-f also. try typing "echo " then crtl-d, then enter. it should show a diamond. but i agree with jcaldwel, a dependency on DOS is probably not a good idea, although i would be interested to know what representations these characters have on other systems...
hope this is what you were looking for
0
All Courses

From novice to tech pro — start learning today.