category fix

main
Jens 2024-05-06 15:57:22 +02:00
parent 40ff3b0779
commit e2b89266b1
15 changed files with 30 additions and 30 deletions

View File

@ -26,7 +26,7 @@ public class Category {
return scored; return scored;
} }
public int getScore(){ public int getScore(int[] values){
return score; return score;
} }

View File

@ -20,11 +20,11 @@ public class Fives extends Category{
} }
@Override @Override
public int getScore(){ public int getScore(int[] values){
int score = 0; int score = 0;
for(int i : player.getDice().getValues()){ for(int i : values){
if( i == 5 ){ if( i == 5 ){
score += i; score += 5;
} }
} }
return score; return score;

View File

@ -34,7 +34,7 @@ public class FourPairs extends Category{
} }
@Override @Override
public int getScore(){ public int getScore(int[] values){
if(one == 4){ if(one == 4){
return 4; return 4;
} }

View File

@ -20,11 +20,11 @@ public class Fours extends Category{
} }
@Override @Override
public int getScore(){ public int getScore(int[] values){
int score = 0; int score = 0;
for(int i : player.getDice().getValues()){ for(int i : values){
if( i == 4 ){ if( i == 4 ){
score += i; score += 4;
} }
} }
return score; return score;

View File

@ -33,7 +33,7 @@ public class FullHouse extends Category{
} }
@Override @Override
public int getScore(){ public int getScore(int[] values){
return 30; return 30;
} }

View File

@ -20,11 +20,11 @@ public class Ones extends Category{
} }
@Override @Override
public int getScore(){ public int getScore(int[] values){
int score = 0; int score = 0;
for (int value : player.getDice().getValues()) { for (int i : values) {
if (value == 1) { if (i == 1) {
score += value; score += 1;
} }
} }
return score; return score;

View File

@ -11,7 +11,7 @@ public class RoyalStraightFlush extends Category{
int one = 0, two = 0, three = 0, four = 0, five = 0; int one = 0, two = 0, three = 0, four = 0, five = 0;
for(int i = 0; i < values.length; i++){ for(int i = 0; i < values.length; i++){
switch(i){ switch(values[i]){
case 1: case 1:
one += 1; one += 1;
case 2: case 2:
@ -33,7 +33,7 @@ public class RoyalStraightFlush extends Category{
} }
@Override @Override
public int getScore(){ public int getScore(int[] values){
return 45; return 45;
} }
} }

View File

@ -20,11 +20,11 @@ public class Sixes extends Category{
} }
@Override @Override
public int getScore(){ public int getScore(int[] values){
int score = 0; int score = 0;
for(int i : player.getDice().getValues()){ for(int i : values){
if( i == 6 ){ if( i == 6 ){
score += i; score += 6;
} }
} }
return score; return score;

View File

@ -11,7 +11,7 @@ public class StraightFlush extends Category{
int one = 0, two = 0, three = 0, four = 0, five = 0; int one = 0, two = 0, three = 0, four = 0, five = 0;
for(int i = 0; i < values.length; i++){ for(int i = 0; i < values.length; i++){
switch(i){ switch(values[i]){
case 1: case 1:
one += 1; one += 1;
case 2: case 2:
@ -33,7 +33,7 @@ public class StraightFlush extends Category{
} }
@Override @Override
public int getScore(){ public int getScore(int[] values){
return 35; return 35;
} }
} }

View File

@ -34,7 +34,7 @@ public class ThreePairs extends Category{
} }
@Override @Override
public int getScore(){ public int getScore(int[] values){
if(one == 4){ if(one == 4){
return 4; return 4;

View File

@ -20,11 +20,11 @@ public class Threes extends Category{
} }
@Override @Override
public int getScore(){ public int getScore(int[] values){
int score = 0; int score = 0;
for(int i : player.getDice().getValues()){ for(int i : values){
if( i == 3 ){ if( i == 3 ){
score += i; score += 3;
} }
} }
return score; return score;

View File

@ -36,7 +36,7 @@ public class TwoPairs extends Category{
} }
@Override @Override
public int getScore(){ public int getScore(int[] values){
if(one == 2){ if(one == 2){
return 2; return 2;

View File

@ -20,11 +20,11 @@ public class Twos extends Category{
} }
@Override @Override
public int getScore(){ public int getScore(int[] values){
int score = 0; int score = 0;
for(int i : player.getDice().getValues()){ for(int i : values){
if( i == 2 ){ if( i == 2 ){
score += i; score += 2;
} }
} }
return score; return score;

View File

@ -33,7 +33,7 @@ public class Yatzy extends Category{
} }
@Override @Override
public int getScore(){ public int getScore(int[] values){
return 75; return 75;
} }
} }

View File

@ -10,7 +10,7 @@ public class Yatzy_Sheet {
public void addScore(int categoryNumber, int score){ public void addScore(int categoryNumber, int score){
for(int i = 0; i < 14; i++){ for(int i = 0; i < 14; i++){
if(i == categoryNumber){ if(i == categoryNumber){
tabelle[i] = categoryNumber; tabelle[i] = score;
} }
} }
} }