Skip to content
Snippets Groups Projects
Commit b6c5093b authored by Ethan Robert's avatar Ethan Robert
Browse files

Added tp03

parent 99996365
No related branches found
No related tags found
No related merge requests found
public class Card {
private Color color;
private Rank rank;
public Card (Color color, Rank rank) {
this.color = color;
this.rank = rank;
}
public Card (String color, String rank) {
for (int i = 0; i < Color.values().length; i++) {
if (Color.values()[i].equals(color)) {
this.color = Color.valueOf(color);
}
}
for (int i = 0; i < Rank.values().length; i++) {
if (Rank.values()[i].equals(color)) {
this.rank = Rank.valueOf(rank);
}
}
}
public Color getColor() {
return this.color;
}
public Rank getRank() {
return this.rank;
}
public boolean equals(Card other) {
if (this == other) {
return true;
}
if (other == null) {
return false;
}
if (this.color.equals(other.color) && this.rank.equals(other.rank)) {
return true;
}
return false;
}
public String toString() {
return this.rank.toString() + " of " + this.color.toString();
}
}
\ No newline at end of file
public enum Color {
CLUB, DIAMOND, HEART, SPADE;
}
\ No newline at end of file
public enum Rank {
SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment