Advertisement
Guest User

Untitled

a guest
Mar 20th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. //Deck03.java
  2.  
  3. public class Deck03
  4. {
  5. private String Rank[]={"Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight","Nine","Ten","Jack","Queen","King"};
  6. private int Value[]={1,2,3,4,5,6,7,8,9,10,11,12,13};
  7. private String Suit[]={"Spades","Diamonds","Hearts","Clubs"};
  8.  
  9. private Card[] cards;
  10. private int size;
  11.  
  12. public Deck03()
  13. {
  14. for (int y=0;y<4;y++)
  15. {
  16. for (int q=0;q<13;q++)
  17. {
  18. Card x=new Card(Rank[q],Suit[y],Value[q]);
  19. System.out.println(x.toString());
  20. }
  21. }
  22.  
  23. }
  24. //Card.java
  25.  
  26. public class Card
  27. {
  28.  
  29. private String suit;
  30.  
  31. private String rank;
  32.  
  33. private int value;
  34.  
  35. public Card(String s, String r, int v)
  36.  
  37. {
  38.  
  39. suit = s;
  40.  
  41. rank = r;
  42.  
  43. value = v;
  44.  
  45. }
  46.  
  47. public String getSuit() { return suit; }
  48.  
  49. public String getRank() { return rank; }
  50.  
  51. public int getValue() { return value; }
  52.  
  53. public void setSuit(String s) { suit = s; }
  54.  
  55. public void setRank(String r) { rank = r; }
  56.  
  57. public void setValue(int v) { value = v; }
  58.  
  59. public String toString()
  60.  
  61. {
  62.  
  63. return "[" + suit + ", " + rank + ", " + value + "]";
  64.  
  65. }
  66.  
  67.  
  68.  
  69. public boolean matches(Card otherCard)
  70.  
  71. {
  72.  
  73. return otherCard.getSuit().equals(this.suit)
  74.  
  75. && otherCard.getRank().equals(this.rank)
  76.  
  77. && otherCard.getValue() == this.value;
  78.  
  79. }
  80.  
  81. }
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement