-
Notifications
You must be signed in to change notification settings - Fork 0
/
Card.java
66 lines (54 loc) · 1.24 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
/**
* COSC 310-001 Card Games
* Card.java
*
* A class for storing and retrieving the information stored on a card
* such as it's suit and worth.
*
* @author Colin Diorio
*/
package main;
public class Card {
private Suit suit;
private Worth worth;
// Constructor
public Card(Suit suit, Worth worth) {
super();
this.suit = suit;
this.worth = worth;
}
/**
* Checks if two cards are the exact same suit and worth.
*
* @param anotherObject the object to compare to.
* @return isEqual if the two cards are the same.
*/
@Override
public boolean equals(Object o) {
if ( !( o instanceof Card ) ) return false;
Card card = ( Card ) o;
return ( this.suit == card.getSuit() &&
this.worth == card.getWorth() );
}
/**
* Gets the spoken way you would describe a cards attributes.
*
* @return cardInfo the card info presented normally.
*/
public String toString() {
return this.worth + " of " + this.suit;
}
// Getters and Setters
public Suit getSuit() {
return suit;
}
public void setSuit(Suit suit) {
this.suit = suit;
}
public Worth getWorth() {
return worth;
}
public void setWorth(Worth worth) {
this.worth = worth;
}
}