facade and domain 3

main
Jens 2024-05-06 16:03:55 +02:00
parent e2b89266b1
commit 5d731cc453
14 changed files with 39 additions and 57 deletions

View File

@ -1,12 +1,9 @@
package Domain; package Domain;
public class Fives extends Category{ public class Fives extends Category{
private Player player;
public Fives(Player player) { public Fives() {
super("Fives", "Score of all the fives rolled."); super("Fives", "Score of all the fives rolled.");
this.player = player;
} }
@Override @Override

View File

@ -4,7 +4,7 @@ public class FourPairs extends Category{
private int one = 0, two = 0, three = 0, four = 0, five = 0; 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"); super("Four Pairs", "Four times the same dice");
} }

View File

@ -1,12 +1,9 @@
package Domain; package Domain;
public class Fours extends Category{ public class Fours extends Category{
private Player player;
public Fours(Player player) { public Fours() {
super("Fours", "Score of all the fours rolled."); super("Fours", "Score of all the fours rolled.");
this.player = player;
} }
@Override @Override

View File

@ -2,7 +2,7 @@ package Domain;
public class FullHouse extends Category{ public class FullHouse extends Category{
public FullHouse(Player player) { public FullHouse() {
super("Full House", "1 Pair and 1 triplet"); super("Full House", "1 Pair and 1 triplet");
} }

View File

@ -2,11 +2,8 @@ package Domain;
public class Ones extends Category{ public class Ones extends Category{
private Player player; public Ones() {
public Ones(Player player) {
super("Ones", "Score of all the ones rolled."); super("Ones", "Score of all the ones rolled.");
this.player = player;
} }
@Override @Override

View File

@ -2,7 +2,7 @@ package Domain;
public class RoyalStraightFlush extends Category{ public class RoyalStraightFlush extends Category{
public RoyalStraightFlush(Player player) { public RoyalStraightFlush() {
super("Royal Straight Flush", "1 - 5"); super("Royal Straight Flush", "1 - 5");
} }

View File

@ -1,12 +1,9 @@
package Domain; package Domain;
public class Sixes extends Category{ public class Sixes extends Category{
private Player player;
public Sixes(Player player) { public Sixes() {
super("Sixes", "Score of all the sixes rolled."); super("Sixes", "Score of all the sixes rolled.");
this.player = player;
} }
@Override @Override

View File

@ -2,7 +2,7 @@ package Domain;
public class StraightFlush extends Category{ public class StraightFlush extends Category{
public StraightFlush(Player player) { public StraightFlush() {
super("Straight Flush", "1 - 4 or 2 - 5"); super("Straight Flush", "1 - 4 or 2 - 5");
} }

View File

@ -4,7 +4,7 @@ public class ThreePairs extends Category{
private int one = 0, two = 0, three = 0, four = 0, five = 0; 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"); super("Three Pairs", "Three times the same dice");
} }

View File

@ -1,12 +1,9 @@
package Domain; package Domain;
public class Threes extends Category{ public class Threes extends Category{
private Player player;
public Threes(Player player) { public Threes() {
super("Threes", "Score of all the threes rolled."); super("Threes", "Score of all the threes rolled.");
this.player = player;
} }
@Override @Override

View File

@ -4,7 +4,7 @@ public class TwoPairs extends Category{
private int one = 0, two = 0, three = 0, four = 0, five = 0; 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"); super("Two Pairs", "Two times the same dice");
} }

View File

@ -2,11 +2,8 @@ package Domain;
public class Twos extends Category{ public class Twos extends Category{
private Player player; public Twos() {
public Twos(Player player) {
super("Twos", "Score of all the twos rolled."); super("Twos", "Score of all the twos rolled.");
this.player = player;
} }
@Override @Override

View File

@ -2,7 +2,7 @@ package Domain;
public class Yatzy extends Category{ public class Yatzy extends Category{
public Yatzy(Player player) { public Yatzy() {
super("Yatzy", "five times the same dice"); super("Yatzy", "five times the same dice");
} }

View File

@ -13,19 +13,19 @@ public class Game {
private Player player1; private Player player1;
private Yatzy_Sheet sheet = new Yatzy_Sheet(); private Yatzy_Sheet sheet = new Yatzy_Sheet();
private Ones ones = new Ones(player1); private Ones ones = new Ones();
private Twos twos = new Twos(player1); private Twos twos = new Twos();
private Threes threes = new Threes(player1); private Threes threes = new Threes();
private Fours fours = new Fours(player1); private Fours fours = new Fours();
private Fives fives = new Fives(player1); private Fives fives = new Fives();
private Sixes sixes = new Sixes(player1); private Sixes sixes = new Sixes();
private TwoPairs twoPairs = new TwoPairs(player1); private TwoPairs twoPairs = new TwoPairs();
private ThreePairs threePairs = new ThreePairs(player1); private ThreePairs threePairs = new ThreePairs();
private FourPairs fourPairs = new FourPairs(player1); private FourPairs fourPairs = new FourPairs();
private FullHouse fullHouse = new FullHouse(player1); private FullHouse fullHouse = new FullHouse();
private StraightFlush straightFlush = new StraightFlush(player1); private StraightFlush straightFlush = new StraightFlush();
private RoyalStraightFlush royalStraightFlush = new RoyalStraightFlush(player1); private RoyalStraightFlush royalStraightFlush = new RoyalStraightFlush();
private Yatzy yatzy = new Yatzy(player1); private Yatzy yatzy = new Yatzy();
public void startgame(int playerCount, String[] name, int numberOfDice){ public void startgame(int playerCount, String[] name, int numberOfDice){
@ -45,55 +45,55 @@ public class Game {
switch(category){ switch(category){
case 1: case 1:
ones.correctCategory(diceValues); ones.correctCategory(diceValues);
sheet.addScore(0, ones.getScore()); sheet.addScore(0, ones.getScore(diceValues));
break; break;
case 2: case 2:
twos.correctCategory(diceValues); twos.correctCategory(diceValues);
sheet.addScore(1, twos.getScore()); sheet.addScore(1, twos.getScore(diceValues));
break; break;
case 3: case 3:
threes.correctCategory(diceValues); threes.correctCategory(diceValues);
sheet.addScore(2, threes.getScore()); sheet.addScore(2, threes.getScore(diceValues));
break; break;
case 4: case 4:
fours.correctCategory(diceValues); fours.correctCategory(diceValues);
sheet.addScore(3, fours.getScore()); sheet.addScore(3, fours.getScore(diceValues));
break; break;
case 5: case 5:
fives.correctCategory(diceValues); fives.correctCategory(diceValues);
sheet.addScore(4, fives.getScore()); sheet.addScore(4, fives.getScore(diceValues));
break; break;
case 6: case 6:
sixes.correctCategory(diceValues); sixes.correctCategory(diceValues);
sheet.addScore(5, sixes.getScore()); sheet.addScore(5, sixes.getScore(diceValues));
break; break;
case 7: case 7:
twoPairs.correctCategory(diceValues); twoPairs.correctCategory(diceValues);
sheet.addScore(6, twoPairs.getScore()); sheet.addScore(6, twoPairs.getScore(diceValues));
break; break;
case 8: case 8:
threePairs.correctCategory(diceValues); threePairs.correctCategory(diceValues);
sheet.addScore(7, threePairs.getScore()); sheet.addScore(7, threePairs.getScore(diceValues));
break; break;
case 9: case 9:
fourPairs.correctCategory(diceValues); fourPairs.correctCategory(diceValues);
sheet.addScore(8, fourPairs.getScore()); sheet.addScore(8, fourPairs.getScore(diceValues));
break; break;
case 10: case 10:
fullHouse.correctCategory(diceValues); fullHouse.correctCategory(diceValues);
sheet.addScore(9, fullHouse.getScore()); sheet.addScore(9, fullHouse.getScore(diceValues));
break; break;
case 11: case 11:
straightFlush.correctCategory(diceValues); straightFlush.correctCategory(diceValues);
sheet.addScore(10, straightFlush.getScore()); sheet.addScore(10, straightFlush.getScore(diceValues));
break; break;
case 12: case 12:
royalStraightFlush.correctCategory(diceValues); royalStraightFlush.correctCategory(diceValues);
sheet.addScore(11, royalStraightFlush.getScore()); sheet.addScore(11, royalStraightFlush.getScore(diceValues));
break; break;
case 13: case 13:
yatzy.correctCategory(diceValues); yatzy.correctCategory(diceValues);
sheet.addScore(12, yatzy.getScore()); sheet.addScore(12, yatzy.getScore(diceValues));
break; break;
} }
} }