From 5d731cc4539d00ed60f5ac8336f5045adb6f5d31 Mon Sep 17 00:00:00 2001 From: Jens <3007492@hs-mannheim.de> Date: Mon, 6 May 2024 16:03:55 +0200 Subject: [PATCH] facade and domain 3 --- Domain/Fives.java | 5 +--- Domain/FourPairs.java | 2 +- Domain/Fours.java | 5 +--- Domain/FullHouse.java | 2 +- Domain/Ones.java | 5 +--- Domain/RoyalStraightFlush.java | 2 +- Domain/Sixes.java | 5 +--- Domain/StraightFlush.java | 2 +- Domain/ThreePairs.java | 2 +- Domain/Threes.java | 5 +--- Domain/TwoPairs.java | 2 +- Domain/Twos.java | 5 +--- Domain/Yatzy.java | 2 +- Facade/Game.java | 52 +++++++++++++++++----------------- 14 files changed, 39 insertions(+), 57 deletions(-) diff --git a/Domain/Fives.java b/Domain/Fives.java index f682f8f..ad014b7 100644 --- a/Domain/Fives.java +++ b/Domain/Fives.java @@ -1,12 +1,9 @@ package Domain; public class Fives extends Category{ - - private Player player; - public Fives(Player player) { + public Fives() { super("Fives", "Score of all the fives rolled."); - this.player = player; } @Override diff --git a/Domain/FourPairs.java b/Domain/FourPairs.java index 9d481c1..5fa5bdb 100644 --- a/Domain/FourPairs.java +++ b/Domain/FourPairs.java @@ -4,7 +4,7 @@ public class FourPairs extends Category{ private int one = 0, two = 0, three = 0, four = 0, five = 0; - public FourPairs(Player player) { + public FourPairs() { super("Four Pairs", "Four times the same dice"); } diff --git a/Domain/Fours.java b/Domain/Fours.java index 04e7828..fd4aeb0 100644 --- a/Domain/Fours.java +++ b/Domain/Fours.java @@ -1,12 +1,9 @@ package Domain; public class Fours extends Category{ - - private Player player; - public Fours(Player player) { + public Fours() { super("Fours", "Score of all the fours rolled."); - this.player = player; } @Override diff --git a/Domain/FullHouse.java b/Domain/FullHouse.java index b913570..3f5c384 100644 --- a/Domain/FullHouse.java +++ b/Domain/FullHouse.java @@ -2,7 +2,7 @@ package Domain; public class FullHouse extends Category{ - public FullHouse(Player player) { + public FullHouse() { super("Full House", "1 Pair and 1 triplet"); } diff --git a/Domain/Ones.java b/Domain/Ones.java index 8e31154..29ed9d2 100644 --- a/Domain/Ones.java +++ b/Domain/Ones.java @@ -2,11 +2,8 @@ package Domain; public class Ones extends Category{ - private Player player; - - public Ones(Player player) { + public Ones() { super("Ones", "Score of all the ones rolled."); - this.player = player; } @Override diff --git a/Domain/RoyalStraightFlush.java b/Domain/RoyalStraightFlush.java index 352534c..2564d27 100644 --- a/Domain/RoyalStraightFlush.java +++ b/Domain/RoyalStraightFlush.java @@ -2,7 +2,7 @@ package Domain; public class RoyalStraightFlush extends Category{ - public RoyalStraightFlush(Player player) { + public RoyalStraightFlush() { super("Royal Straight Flush", "1 - 5"); } diff --git a/Domain/Sixes.java b/Domain/Sixes.java index 01177e9..797e9b9 100644 --- a/Domain/Sixes.java +++ b/Domain/Sixes.java @@ -1,12 +1,9 @@ package Domain; public class Sixes extends Category{ - - private Player player; - public Sixes(Player player) { + public Sixes() { super("Sixes", "Score of all the sixes rolled."); - this.player = player; } @Override diff --git a/Domain/StraightFlush.java b/Domain/StraightFlush.java index 0ddb87c..fa1aa1b 100644 --- a/Domain/StraightFlush.java +++ b/Domain/StraightFlush.java @@ -2,7 +2,7 @@ package Domain; public class StraightFlush extends Category{ - public StraightFlush(Player player) { + public StraightFlush() { super("Straight Flush", "1 - 4 or 2 - 5"); } diff --git a/Domain/ThreePairs.java b/Domain/ThreePairs.java index 14395ef..b14bccb 100644 --- a/Domain/ThreePairs.java +++ b/Domain/ThreePairs.java @@ -4,7 +4,7 @@ public class ThreePairs extends Category{ private int one = 0, two = 0, three = 0, four = 0, five = 0; - public ThreePairs(Player player) { + public ThreePairs() { super("Three Pairs", "Three times the same dice"); } diff --git a/Domain/Threes.java b/Domain/Threes.java index 843625f..d7d491a 100644 --- a/Domain/Threes.java +++ b/Domain/Threes.java @@ -1,12 +1,9 @@ package Domain; public class Threes extends Category{ - - private Player player; - public Threes(Player player) { + public Threes() { super("Threes", "Score of all the threes rolled."); - this.player = player; } @Override diff --git a/Domain/TwoPairs.java b/Domain/TwoPairs.java index 5a256ba..4f32261 100644 --- a/Domain/TwoPairs.java +++ b/Domain/TwoPairs.java @@ -4,7 +4,7 @@ public class TwoPairs extends Category{ private int one = 0, two = 0, three = 0, four = 0, five = 0; - public TwoPairs(Player player) { + public TwoPairs() { super("Two Pairs", "Two times the same dice"); } diff --git a/Domain/Twos.java b/Domain/Twos.java index 9bd1e1c..ea148f4 100644 --- a/Domain/Twos.java +++ b/Domain/Twos.java @@ -2,11 +2,8 @@ package Domain; public class Twos extends Category{ - private Player player; - - public Twos(Player player) { + public Twos() { super("Twos", "Score of all the twos rolled."); - this.player = player; } @Override diff --git a/Domain/Yatzy.java b/Domain/Yatzy.java index 62e6d64..721e96d 100644 --- a/Domain/Yatzy.java +++ b/Domain/Yatzy.java @@ -2,7 +2,7 @@ package Domain; public class Yatzy extends Category{ - public Yatzy(Player player) { + public Yatzy() { super("Yatzy", "five times the same dice"); } diff --git a/Facade/Game.java b/Facade/Game.java index e97af03..5fe6acd 100644 --- a/Facade/Game.java +++ b/Facade/Game.java @@ -13,19 +13,19 @@ public class Game { private Player player1; private Yatzy_Sheet sheet = new Yatzy_Sheet(); - private Ones ones = new Ones(player1); - private Twos twos = new Twos(player1); - private Threes threes = new Threes(player1); - private Fours fours = new Fours(player1); - private Fives fives = new Fives(player1); - private Sixes sixes = new Sixes(player1); - private TwoPairs twoPairs = new TwoPairs(player1); - private ThreePairs threePairs = new ThreePairs(player1); - private FourPairs fourPairs = new FourPairs(player1); - private FullHouse fullHouse = new FullHouse(player1); - private StraightFlush straightFlush = new StraightFlush(player1); - private RoyalStraightFlush royalStraightFlush = new RoyalStraightFlush(player1); - private Yatzy yatzy = new Yatzy(player1); + private Ones ones = new Ones(); + private Twos twos = new Twos(); + private Threes threes = new Threes(); + private Fours fours = new Fours(); + private Fives fives = new Fives(); + private Sixes sixes = new Sixes(); + private TwoPairs twoPairs = new TwoPairs(); + private ThreePairs threePairs = new ThreePairs(); + private FourPairs fourPairs = new FourPairs(); + private FullHouse fullHouse = new FullHouse(); + private StraightFlush straightFlush = new StraightFlush(); + private RoyalStraightFlush royalStraightFlush = new RoyalStraightFlush(); + private Yatzy yatzy = new Yatzy(); public void startgame(int playerCount, String[] name, int numberOfDice){ @@ -45,55 +45,55 @@ public class Game { switch(category){ case 1: ones.correctCategory(diceValues); - sheet.addScore(0, ones.getScore()); + sheet.addScore(0, ones.getScore(diceValues)); break; case 2: twos.correctCategory(diceValues); - sheet.addScore(1, twos.getScore()); + sheet.addScore(1, twos.getScore(diceValues)); break; case 3: threes.correctCategory(diceValues); - sheet.addScore(2, threes.getScore()); + sheet.addScore(2, threes.getScore(diceValues)); break; case 4: fours.correctCategory(diceValues); - sheet.addScore(3, fours.getScore()); + sheet.addScore(3, fours.getScore(diceValues)); break; case 5: fives.correctCategory(diceValues); - sheet.addScore(4, fives.getScore()); + sheet.addScore(4, fives.getScore(diceValues)); break; case 6: sixes.correctCategory(diceValues); - sheet.addScore(5, sixes.getScore()); + sheet.addScore(5, sixes.getScore(diceValues)); break; case 7: twoPairs.correctCategory(diceValues); - sheet.addScore(6, twoPairs.getScore()); + sheet.addScore(6, twoPairs.getScore(diceValues)); break; case 8: threePairs.correctCategory(diceValues); - sheet.addScore(7, threePairs.getScore()); + sheet.addScore(7, threePairs.getScore(diceValues)); break; case 9: fourPairs.correctCategory(diceValues); - sheet.addScore(8, fourPairs.getScore()); + sheet.addScore(8, fourPairs.getScore(diceValues)); break; case 10: fullHouse.correctCategory(diceValues); - sheet.addScore(9, fullHouse.getScore()); + sheet.addScore(9, fullHouse.getScore(diceValues)); break; case 11: straightFlush.correctCategory(diceValues); - sheet.addScore(10, straightFlush.getScore()); + sheet.addScore(10, straightFlush.getScore(diceValues)); break; case 12: royalStraightFlush.correctCategory(diceValues); - sheet.addScore(11, royalStraightFlush.getScore()); + sheet.addScore(11, royalStraightFlush.getScore(diceValues)); break; case 13: yatzy.correctCategory(diceValues); - sheet.addScore(12, yatzy.getScore()); + sheet.addScore(12, yatzy.getScore(diceValues)); break; } }