fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Testing black jack dealing code. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int[][] values = initDeal(5);
  13. for(int[] val : values)
  14. {
  15. // Cycle through each value and print out the hands.
  16. System.out.println("First Card: " + val[0] + "\nSecond Card: " + val[1]);
  17. }
  18. }
  19.  
  20. /**
  21. * Supplied method for printing out the hands.
  22. */
  23. public static int[][] initDeal(int NPlayers)
  24. {
  25. int hands[][] = new int[NPlayers][2];
  26.  
  27. for(int a = 0; a<NPlayers; a++)
  28. {
  29.  
  30. hands[a][0] = (int)Math.round((Math.random() * 13))-1;
  31. hands[a][1] = (int)Math.round((Math.random() * 13))-1;
  32.  
  33. }
  34. return hands;
  35. }
  36. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
First Card: 2
Second Card: 9
First Card: 8
Second Card: 10
First Card: 1
Second Card: 1
First Card: 3
Second Card: 4
First Card: 2
Second Card: 12