Yatzy/Domain/Ones.java

31 lines
532 B
Java
Raw Normal View History

2024-05-03 21:10:44 +02:00
package Domain;
public class Ones extends Category{
2024-05-06 16:03:55 +02:00
public Ones() {
2024-05-03 21:10:44 +02:00
super("Ones", "Score of all the ones rolled.");
}
@Override
public boolean correctCategory(int[] values){
for(int i : values){
if(i == 1){
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) {
if (i == 1) {
score += 1;
2024-05-03 21:10:44 +02:00
}
}
return score;
}
}