-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard.java
67 lines (60 loc) · 1.77 KB
/
Card.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
public class Card
{
// instance variables - replace the example below with your own
private Suit suit;
private Rank rank;
public Card(Rank Rank, Suit Suit)
{
// initialise instance variables
suit = Suit;
rank = Rank;
}
public Rank getRank(){
return rank;
}
public Suit getSuit(){
return suit;
}
public void print()
{
if (rank.getPointValue()>=2 && rank.getPointValue()<=10){
System.out.println(rank.getPointValue() + " of " + suit.name());
}
else{
System.out.println(rank.name() + " of " + suit.name());
}
}
/**
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
public boolean matches(Card other)
{
return rank==other.rank && suit==other.suit;
}
}
// public class Main
// {
// public static void main(String[] args)
// {
// Card s1 = new Card(Rank.Ten,Suit.Spades);
// Card s2 = new Card(Rank.Ten, Suit.Spades);
// Card r3 = new Card(Rank.Ten, Suit.Diamonds);
// Card b4 = new Card(Rank.Nine, Suit.Spades);
// System.out.println(s1.matches(s2));
// Deck decker = new Deck(Rank.values(), Suit.values());
// System.out.println(decker.size());
// System.out.println(decker.deal());
// System.out.println(decker.deal());
// System.out.println(decker.deal());
// System.out.println(decker.deal());
// System.out.println(decker.size());
// while (decker.isEmpty()==false)
// {
// decker.deal();
// }
// }
// //the deck contains the 1 of each card and suit
// }