Advertisement
Guest User

Untitled

a guest
Nov 27th, 2017
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.42 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Deck {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.  
  8.         int cardIndex = scanner.nextInt() - 1;
  9.         int card = 2 + cardIndex / 4;
  10.         int suit = cardIndex % 4;
  11.  
  12.         for (int i = cardIndex; i < 52; i++) {
  13.             if (card <= 10) {
  14.                 System.out.print(card);
  15.             } else if (card == 11) {
  16.                 System.out.print('J');
  17.             } else if (card == 12) {
  18.                 System.out.print('D');
  19.             } else if (card == 13) {
  20.                 System.out.print('K');
  21.             } else if (card == 14) {
  22.                 System.out.print('A');
  23.             }
  24.  
  25.             if (suit == 0) {
  26.                 System.out.print((char) 0x2663);
  27.             } else if (suit == 1) {
  28.                 System.out.print((char) 0x2666);
  29.             } else if (suit == 2) {
  30.                 System.out.print((char) 0x2665);
  31.             } else if (suit == 3) {
  32.                 System.out.print((char) 0x2664);
  33.             }
  34.  
  35.             if (i < 51) {
  36.                 System.out.print(',');
  37.                 System.out.print(' ');
  38.             } else {
  39.                 System.out.println();
  40.             }
  41.  
  42.             if (i % 4 == 3) {
  43.                 card++;
  44.             }
  45.  
  46.             suit++;
  47.             if (suit > 3) {
  48.                 suit = 0;
  49.             }
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement