Skip to content

Commit

Permalink
Add points.
Browse files Browse the repository at this point in the history
  • Loading branch information
tecimovic committed Jan 12, 2024
1 parent 9871a45 commit d0ddf69
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/main/java/programming/school/tarok/TarokCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,42 @@ public class TarokCard {
private TarockValue tarockValue;
private SuitValue suitValue;

/**
* Initializes the card, either suitValue or tarockValue is used, depending on
* Suit.
*
* @param suit
* @param suitValue
* @param tarockValue
*/
public TarokCard(Suit suit, SuitValue suitValue, TarockValue tarockValue) {
if (suit == null)
throw new IllegalArgumentException("You must pass valid suit.");
this.suit = suit;
if (suit == Suit.Tarok) {
if (tarockValue == null)
throw new IllegalArgumentException("You must pass valid tarockValue for the tarock suit.");
this.tarockValue = tarockValue;
} else {
if (suitValue == null)
throw new IllegalArgumentException("You must pass valid suitValue for the non-tarock suit.");
this.suitValue = suitValue;
}
}

/**
* How many points is this card worth at the final count.
*
* @return
*/
public int points() {
if (suit == Suit.Tarok) {
return tarockValue.points();
} else {
return suitValue.points();
}
}

private String redName(SuitValue value) {
switch (value) {
case Tiny:
Expand Down

0 comments on commit d0ddf69

Please sign in to comment.