-
Notifications
You must be signed in to change notification settings - Fork 0
/
FixedAmountRow.java
41 lines (38 loc) · 1.05 KB
/
FixedAmountRow.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
/**
* {@link FixedAmountRow} is an abstraction of {@link ScoreRow} that implements
* the score calculations in {@link #calculateScore(Dice)} for all its
* sub-classes.
*
* @see #calculateScore(Dice)
* @see ScoreRow
* @see FullHouseRow
* @see StraightRow
* @see YahtzeeRow
*/
public abstract class FixedAmountRow extends ScoreRow {
private int scoreValue;
/**
* Represent scoring for rows with a fixed score.
*
* @param name The scoring row's name.
* @param scoreValue How much the row scores.
* <p>
* Ex. Full House - 25.
*/
public FixedAmountRow(String name, int scoreValue) {
super(name);
this.scoreValue = scoreValue;
}
/**
* {@inheritDoc}
* For {@link FixedAmountRow}, the score is given by {@link #scoreValue}.
*
* @see ScoreRow#calculateScore(Dice)
*/
public void calculateScore(Dice dice) {
if (!this.isValid(dice))
this.setScore(0);
else
this.setScore(scoreValue);
}
}