willieshi232

Untitled

Feb 22nd, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. import java.util.*;
  2. public class Card
  3. {
  4. private String suit;
  5. private int Value;
  6. public Card(String suit, int Value)
  7. {
  8. this.suit = suit;
  9. this.Value = Value;
  10. if(!suit.equals("SPADE") && !suit.equals("HEART") && !suit.equals("CLUB") && !suit.equals("DIAMOND"))
  11. {
  12. System.out.println("That's not a usuable suit");
  13. }
  14. if(Value < 1 || Value > 14)
  15. {
  16. System.out.println("That's not usuable value");
  17. }
  18. }
  19.  
  20. public String getSuit(String suit)
  21. {
  22. return suit;
  23. }
  24.  
  25. public int getValue(int Value)
  26. {
  27. return Value;
  28. }
  29.  
  30. public String toString(String suit, int Value)
  31. {
  32. if(Value == 11)
  33. {
  34. return "Suit:" + suit + "Value: Jack";
  35. }
  36. if(Value == 12)
  37. {
  38. return "Suit:" + suit + "Value: Queen";
  39. }
  40. if(Value == 13)
  41. {
  42. return "Suit:" + suit + "Value: King";
  43. }
  44. if(Value > 0 && Value < 11)
  45. {
  46. return "Suit:" + suit + " Value" + Value;
  47. }
  48. return null;
  49. }
  50. }
  51.  
  52. public class Deck
  53. {
  54. private int count = 1;
  55. public Deck()
  56. {
  57. Card[] deck = new Card[52];
  58. int[] Values = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
  59. String[] Suites = {"Spade", "Heart", "Clubs", "Diamond"};
  60. for(int V = 0; V < 12; V++)
  61. {
  62. for(int S = 0; S < 4; S++)
  63. {
  64. for(int i = 0; i < 52; i++)
  65. {
  66. Card card = new Card(Suites[S], Values[V]);
  67. deck[i] = card;
  68. if(count != 4)
  69. {
  70. V--;
  71. count++;
  72. }
  73. if(count == 4)
  74. {
  75. count = 0;
  76. }
  77. }
  78. }
  79. }
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment