From e2b89266b13552311e503b2f4c34583472f8412a Mon Sep 17 00:00:00 2001 From: Jens <3007492@hs-mannheim.de> Date: Mon, 6 May 2024 15:57:22 +0200 Subject: [PATCH] category fix --- Domain/Category.java | 2 +- Domain/Fives.java | 6 +++--- Domain/FourPairs.java | 2 +- Domain/Fours.java | 6 +++--- Domain/FullHouse.java | 2 +- Domain/Ones.java | 8 ++++---- Domain/RoyalStraightFlush.java | 4 ++-- Domain/Sixes.java | 6 +++--- Domain/StraightFlush.java | 4 ++-- Domain/ThreePairs.java | 2 +- Domain/Threes.java | 6 +++--- Domain/TwoPairs.java | 2 +- Domain/Twos.java | 6 +++--- Domain/Yatzy.java | 2 +- Domain/Yatzy_Sheet.java | 2 +- 15 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Domain/Category.java b/Domain/Category.java index d33038d..4d397a8 100644 --- a/Domain/Category.java +++ b/Domain/Category.java @@ -26,7 +26,7 @@ public class Category { return scored; } - public int getScore(){ + public int getScore(int[] values){ return score; } diff --git a/Domain/Fives.java b/Domain/Fives.java index b0bd741..f682f8f 100644 --- a/Domain/Fives.java +++ b/Domain/Fives.java @@ -20,11 +20,11 @@ public class Fives extends Category{ } @Override - public int getScore(){ + public int getScore(int[] values){ int score = 0; - for(int i : player.getDice().getValues()){ + for(int i : values){ if( i == 5 ){ - score += i; + score += 5; } } return score; diff --git a/Domain/FourPairs.java b/Domain/FourPairs.java index 15a536d..9d481c1 100644 --- a/Domain/FourPairs.java +++ b/Domain/FourPairs.java @@ -34,7 +34,7 @@ public class FourPairs extends Category{ } @Override - public int getScore(){ + public int getScore(int[] values){ if(one == 4){ return 4; } diff --git a/Domain/Fours.java b/Domain/Fours.java index 7a386fb..04e7828 100644 --- a/Domain/Fours.java +++ b/Domain/Fours.java @@ -20,11 +20,11 @@ public class Fours extends Category{ } @Override - public int getScore(){ + public int getScore(int[] values){ int score = 0; - for(int i : player.getDice().getValues()){ + for(int i : values){ if( i == 4 ){ - score += i; + score += 4; } } return score; diff --git a/Domain/FullHouse.java b/Domain/FullHouse.java index 588a34a..b913570 100644 --- a/Domain/FullHouse.java +++ b/Domain/FullHouse.java @@ -33,7 +33,7 @@ public class FullHouse extends Category{ } @Override - public int getScore(){ + public int getScore(int[] values){ return 30; } diff --git a/Domain/Ones.java b/Domain/Ones.java index 47acb0b..8e31154 100644 --- a/Domain/Ones.java +++ b/Domain/Ones.java @@ -20,11 +20,11 @@ public class Ones extends Category{ } @Override - public int getScore(){ + public int getScore(int[] values){ int score = 0; - for (int value : player.getDice().getValues()) { - if (value == 1) { - score += value; + for (int i : values) { + if (i == 1) { + score += 1; } } return score; diff --git a/Domain/RoyalStraightFlush.java b/Domain/RoyalStraightFlush.java index 2347cbf..352534c 100644 --- a/Domain/RoyalStraightFlush.java +++ b/Domain/RoyalStraightFlush.java @@ -11,7 +11,7 @@ public class RoyalStraightFlush extends Category{ int one = 0, two = 0, three = 0, four = 0, five = 0; for(int i = 0; i < values.length; i++){ - switch(i){ + switch(values[i]){ case 1: one += 1; case 2: @@ -33,7 +33,7 @@ public class RoyalStraightFlush extends Category{ } @Override - public int getScore(){ + public int getScore(int[] values){ return 45; } } diff --git a/Domain/Sixes.java b/Domain/Sixes.java index 895d05a..01177e9 100644 --- a/Domain/Sixes.java +++ b/Domain/Sixes.java @@ -20,11 +20,11 @@ public class Sixes extends Category{ } @Override - public int getScore(){ + public int getScore(int[] values){ int score = 0; - for(int i : player.getDice().getValues()){ + for(int i : values){ if( i == 6 ){ - score += i; + score += 6; } } return score; diff --git a/Domain/StraightFlush.java b/Domain/StraightFlush.java index f9bfcd5..0ddb87c 100644 --- a/Domain/StraightFlush.java +++ b/Domain/StraightFlush.java @@ -11,7 +11,7 @@ public class StraightFlush extends Category{ int one = 0, two = 0, three = 0, four = 0, five = 0; for(int i = 0; i < values.length; i++){ - switch(i){ + switch(values[i]){ case 1: one += 1; case 2: @@ -33,7 +33,7 @@ public class StraightFlush extends Category{ } @Override - public int getScore(){ + public int getScore(int[] values){ return 35; } } diff --git a/Domain/ThreePairs.java b/Domain/ThreePairs.java index 38723b8..14395ef 100644 --- a/Domain/ThreePairs.java +++ b/Domain/ThreePairs.java @@ -34,7 +34,7 @@ public class ThreePairs extends Category{ } @Override - public int getScore(){ + public int getScore(int[] values){ if(one == 4){ return 4; diff --git a/Domain/Threes.java b/Domain/Threes.java index c9ac324..843625f 100644 --- a/Domain/Threes.java +++ b/Domain/Threes.java @@ -20,11 +20,11 @@ public class Threes extends Category{ } @Override - public int getScore(){ + public int getScore(int[] values){ int score = 0; - for(int i : player.getDice().getValues()){ + for(int i : values){ if( i == 3 ){ - score += i; + score += 3; } } return score; diff --git a/Domain/TwoPairs.java b/Domain/TwoPairs.java index 822b133..5a256ba 100644 --- a/Domain/TwoPairs.java +++ b/Domain/TwoPairs.java @@ -36,7 +36,7 @@ public class TwoPairs extends Category{ } @Override - public int getScore(){ + public int getScore(int[] values){ if(one == 2){ return 2; diff --git a/Domain/Twos.java b/Domain/Twos.java index 57913bf..9bd1e1c 100644 --- a/Domain/Twos.java +++ b/Domain/Twos.java @@ -20,11 +20,11 @@ public class Twos extends Category{ } @Override - public int getScore(){ + public int getScore(int[] values){ int score = 0; - for(int i : player.getDice().getValues()){ + for(int i : values){ if( i == 2 ){ - score += i; + score += 2; } } return score; diff --git a/Domain/Yatzy.java b/Domain/Yatzy.java index 894509f..62e6d64 100644 --- a/Domain/Yatzy.java +++ b/Domain/Yatzy.java @@ -33,7 +33,7 @@ public class Yatzy extends Category{ } @Override - public int getScore(){ + public int getScore(int[] values){ return 75; } } diff --git a/Domain/Yatzy_Sheet.java b/Domain/Yatzy_Sheet.java index d2c3614..9bc5af8 100644 --- a/Domain/Yatzy_Sheet.java +++ b/Domain/Yatzy_Sheet.java @@ -10,7 +10,7 @@ public class Yatzy_Sheet { public void addScore(int categoryNumber, int score){ for(int i = 0; i < 14; i++){ if(i == categoryNumber){ - tabelle[i] = categoryNumber; + tabelle[i] = score; } } }