Yatzy/Domain/StraightFlush.java

40 lines
939 B
Java
Raw Permalink Normal View History

2024-05-03 21:10:44 +02:00
package Domain;
public class StraightFlush extends Category{
2024-05-06 16:03:55 +02:00
public StraightFlush() {
2024-05-03 21:10:44 +02:00
super("Straight Flush", "1 - 4 or 2 - 5");
}
@Override
public boolean correctCategory(int[] values){
int one = 0, two = 0, three = 0, four = 0, five = 0;
for(int i = 0; i < values.length; i++){
2024-05-06 15:57:22 +02:00
switch(values[i]){
2024-05-03 21:10:44 +02:00
case 1:
one += 1;
case 2:
two += 1;
case 3:
three += 1;
case 4:
four += 1;
case 5:
five += 1;
break;
}
}
if((one == 1 && two == 1 && three == 1 && four == 1) || (two == 1 && three == 1 && four == 1 && five == 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
return 35;
}
}