Yatzy/Domain/Twos.java

34 lines
625 B
Java
Raw Normal View History

2024-05-03 21:10:44 +02:00
package Domain;
public class Twos extends Category{
private Player player;
public Twos(Player player) {
super("Twos", "Score of all the twos rolled.");
this.player = player;
}
@Override
public boolean correctCategory(int[] values){
for(int i : values){
if(i == 2){
return true;
}
}
return false;
}
@Override
2024-05-06 15:57:22 +02:00
public int getScore(int[] values){
2024-05-03 21:10:44 +02:00
int score = 0;
2024-05-06 15:57:22 +02:00
for(int i : values){
2024-05-03 21:10:44 +02:00
if( i == 2 ){
2024-05-06 15:57:22 +02:00
score += 2;
2024-05-03 21:10:44 +02:00
}
}
return score;
}
}