Advertisement
Jumbuck

Tarot cards code

Jun 19th, 2015
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.33 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.Scanner;
  3. public class TarotCards {
  4. public static Random draw = new Random();
  5. public static Scanner scan = new Scanner(System.in);
  6. public static int numDraws=0;
  7. public static int theCard;
  8.  
  9. public static void main(String[] args) {
  10. //A total of 78 cards
  11. //System.out.println(draw.nextInt(78)+1);
  12. String again="";
  13. while(!again.contains("n")){
  14. System.out.println("How many cards do you want to draw?");
  15. numDraws=scan.nextInt();
  16. while(numDraws>77){
  17. System.out.println("Too many cards.");
  18. System.out.println("How many cards do you want to draw?");
  19. numDraws=scan.nextInt();
  20. }
  21.  
  22. System.out.println("Cards drawn:\n");
  23. int [] cardsDrawn = new int[numDraws];
  24. for(int i=0; i<numDraws; i++){
  25. theCard=draw.nextInt(78);
  26. checkDupe(cardsDrawn);
  27. cardsDrawn[i]=theCard;
  28. System.out.println(getCard(theCard));
  29. }
  30. System.out.println("\nContinue?");
  31. again=scan.next();
  32. System.out.println();
  33. }
  34. /*
  35. String cont ="";
  36. while(!cont.contains("n")){
  37. System.out.print("Enter a number: ");
  38. theCard=scan.nextInt();
  39. System.out.println(getCard(theCard));
  40. System.out.println("Continue?");
  41. cont=scan.nextLine();
  42. }
  43. */
  44.  
  45. }
  46. public static void checkDupe(int[] cards){
  47. for(int i=0; i<cards.length; i++){
  48. if(cards[i]==theCard){
  49. theCard=draw.nextInt(78);
  50. checkDupe(cards);
  51. }
  52. }
  53. }
  54. public static String getCard(int num){
  55. String inversed = "";
  56. if(draw.nextBoolean())
  57. inversed = " inversed";
  58. if(num<22){
  59. return majorArcana(num)+inversed;
  60. }
  61. else
  62. return minorArcana(num)+inversed;
  63. }
  64.  
  65. public static String minorArcana(int num){
  66. String suit="";
  67. String space="";
  68. int card=0;
  69. if(22<=num && num<36){
  70. suit="pentacles";
  71. card=num-21;
  72. }
  73. if(36<=num && num<50){
  74. suit="swords";
  75. card=num-35;
  76. }
  77. if(50<=num && num<64){
  78. suit="wands";
  79. card=num-49;
  80. }
  81. if(64<=num && num<=77){
  82. suit="cups";
  83. card=num-63;
  84. }
  85. String newCard=facedCards(card);
  86.  
  87. return newCard+" of "+suit;
  88. /*
  89. pentacles, swords, wands, and cups
  90. king, queen, knight and page and then 10-1 in the numbers
  91. */
  92. }
  93. public static String facedCards(int num){
  94. if(num==11)
  95. return "page";
  96. if(num==12)
  97. return "knight";
  98. if(num==13)
  99. return "queen";
  100. if(num==14)
  101. return "king";
  102. else
  103. return num+"";
  104. }
  105. public static String majorArcana(int num){
  106. if(num==0)
  107. return "the fool";
  108. if(num==1)
  109. return "the magician";
  110. if(num==2)
  111. return "the high priestess";
  112. if(num==3)
  113. return "the empress";
  114. if(num==4)
  115. return "the emperor";
  116. if(num==5)
  117. return "the hierophant";
  118. if(num==6)
  119. return "the lovers";
  120. if(num==7)
  121. return "the chariot";
  122. if(num==8)
  123. return "strength";
  124. if(num==9)
  125. return "the hermit";
  126. if(num==10)
  127. return "the wheel of fortune";
  128. if(num==11)
  129. return "justice";
  130. if(num==12)
  131. return "the hanged man";
  132. if(num==13)
  133. return "death";
  134. if(num==14)
  135. return "temperance";
  136. if(num==15)
  137. return "the devil";
  138. if(num==16)
  139. return "the tower";
  140. if(num==17)
  141. return "the star";
  142. if(num==18)
  143. return "the moon";
  144. if(num==19)
  145. return "the sun";
  146. if(num==20)
  147. return "judgement";
  148. else
  149. return "the world";
  150. }
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement