diff --git a/Domain/Category.java b/Domain/Category.java index 6facea9..d33038d 100644 --- a/Domain/Category.java +++ b/Domain/Category.java @@ -7,11 +7,11 @@ public class Category { private boolean scored; private int score; - public Category(String name, String description, boolean scored, int score){ + public Category(String name, String description){ this.name = name; this.description = description; this.scored = false; - this.score = score; + this.score = 0; } public String getName(){ @@ -30,7 +30,7 @@ public class Category { return score; } - public boolean correctCategory(){ + public boolean correctCategory(int[] values){ return true; } } diff --git a/Domain/Fives.java b/Domain/Fives.java new file mode 100644 index 0000000..b0bd741 --- /dev/null +++ b/Domain/Fives.java @@ -0,0 +1,32 @@ +package Domain; + +public class Fives extends Category{ + + private Player player; + + public Fives(Player player) { + super("Fives", "Score of all the fives rolled."); + this.player = player; + } + + @Override + public boolean correctCategory(int[] values){ + for(int i : values){ + if(i == 5){ + return true; + } + } + return false; + } + + @Override + public int getScore(){ + int score = 0; + for(int i : player.getDice().getValues()){ + if( i == 5 ){ + score += i; + } + } + return score; + } +} diff --git a/Domain/FourPairs.java b/Domain/FourPairs.java new file mode 100644 index 0000000..48a12ab --- /dev/null +++ b/Domain/FourPairs.java @@ -0,0 +1,5 @@ +package Domain; + +public class FourPairs { + +} diff --git a/Domain/Fours.java b/Domain/Fours.java new file mode 100644 index 0000000..7a386fb --- /dev/null +++ b/Domain/Fours.java @@ -0,0 +1,32 @@ +package Domain; + +public class Fours extends Category{ + + private Player player; + + public Fours(Player player) { + super("Fours", "Score of all the fours rolled."); + this.player = player; + } + + @Override + public boolean correctCategory(int[] values){ + for(int i : values){ + if(i == 4){ + return true; + } + } + return false; + } + + @Override + public int getScore(){ + int score = 0; + for(int i : player.getDice().getValues()){ + if( i == 4 ){ + score += i; + } + } + return score; + } +} diff --git a/Domain/FullHouse.java b/Domain/FullHouse.java new file mode 100644 index 0000000..588a34a --- /dev/null +++ b/Domain/FullHouse.java @@ -0,0 +1,40 @@ +package Domain; + +public class FullHouse extends Category{ + + public FullHouse(Player player) { + super("Full House", "1 Pair and 1 triplet"); + } + + @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++){ + switch(i){ + case 1: + one += 1; + case 2: + two += 1; + case 3: + three += 1; + case 4: + four += 1; + case 5: + five += 1; + break; + } + } + if((one == 3 || two == 3 || three == 3 || four == 3 || five == 3) && (one == 2 || two == 2 || three == 2 || four == 2 || five == 2)){ + return true; + } + + return false; + } + + @Override + public int getScore(){ + return 30; + } + +} diff --git a/Domain/Ones.java b/Domain/Ones.java new file mode 100644 index 0000000..47acb0b --- /dev/null +++ b/Domain/Ones.java @@ -0,0 +1,33 @@ +package Domain; + +public class Ones extends Category{ + + private Player player; + + public Ones(Player player) { + super("Ones", "Score of all the ones rolled."); + this.player = player; + } + + @Override + public boolean correctCategory(int[] values){ + for(int i : values){ + if(i == 1){ + return true; + } + } + return false; + } + + @Override + public int getScore(){ + int score = 0; + for (int value : player.getDice().getValues()) { + if (value == 1) { + score += value; + } + } + return score; + } + +} diff --git a/Domain/Player.java b/Domain/Player.java index d25f44e..a8fec2f 100644 --- a/Domain/Player.java +++ b/Domain/Player.java @@ -4,11 +4,13 @@ public class Player { private String name; private Yatzy_Sheet sheet; + private Dice dice; - public Player(String name, Yatzy_Sheet sheet){ + public Player(String name, Yatzy_Sheet sheet, Dice dice){ this.name = name; this.sheet = sheet; + this.dice = dice; } public String getName(){ @@ -18,4 +20,8 @@ public class Player { public Yatzy_Sheet getSheet(){ return sheet; } + + public Dice getDice(){ + return dice; + } } diff --git a/Domain/RoyalStraightFlush.java b/Domain/RoyalStraightFlush.java new file mode 100644 index 0000000..2347cbf --- /dev/null +++ b/Domain/RoyalStraightFlush.java @@ -0,0 +1,39 @@ +package Domain; + +public class RoyalStraightFlush extends Category{ + + public RoyalStraightFlush(Player player) { + super("Royal Straight Flush", "1 - 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++){ + switch(i){ + 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 && five == 1){ + return true; + } + + return false; + } + + @Override + public int getScore(){ + return 45; + } +} diff --git a/Domain/Sixes.java b/Domain/Sixes.java new file mode 100644 index 0000000..895d05a --- /dev/null +++ b/Domain/Sixes.java @@ -0,0 +1,32 @@ +package Domain; + +public class Sixes extends Category{ + + private Player player; + + public Sixes(Player player) { + super("Sixes", "Score of all the sixes rolled."); + this.player = player; + } + + @Override + public boolean correctCategory(int[] values){ + for(int i : values){ + if(i == 6){ + return true; + } + } + return false; + } + + @Override + public int getScore(){ + int score = 0; + for(int i : player.getDice().getValues()){ + if( i == 6 ){ + score += i; + } + } + return score; + } +} diff --git a/Domain/StraightFlush.java b/Domain/StraightFlush.java new file mode 100644 index 0000000..f9bfcd5 --- /dev/null +++ b/Domain/StraightFlush.java @@ -0,0 +1,39 @@ +package Domain; + +public class StraightFlush extends Category{ + + public StraightFlush(Player player) { + 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++){ + switch(i){ + 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 + public int getScore(){ + return 35; + } +} diff --git a/Domain/ThreePairs.java b/Domain/ThreePairs.java new file mode 100644 index 0000000..ca63f24 --- /dev/null +++ b/Domain/ThreePairs.java @@ -0,0 +1,10 @@ +package Domain; + +public class ThreePairs extends Category{ + + public ThreePairs(String name, String description) { + super(name, description); + //TODO Auto-generated constructor stub + } + +} diff --git a/Domain/Threes.java b/Domain/Threes.java new file mode 100644 index 0000000..c9ac324 --- /dev/null +++ b/Domain/Threes.java @@ -0,0 +1,32 @@ +package Domain; + +public class Threes extends Category{ + + private Player player; + + public Threes(Player player) { + super("Threes", "Score of all the threes rolled."); + this.player = player; + } + + @Override + public boolean correctCategory(int[] values){ + for(int i : values){ + if(i == 3){ + return true; + } + } + return false; + } + + @Override + public int getScore(){ + int score = 0; + for(int i : player.getDice().getValues()){ + if( i == 3 ){ + score += i; + } + } + return score; + } +} diff --git a/Domain/TwoPairs.java b/Domain/TwoPairs.java new file mode 100644 index 0000000..2ed22c2 --- /dev/null +++ b/Domain/TwoPairs.java @@ -0,0 +1,33 @@ +package Domain; + +public class TwoPairs extends Category{ + + private Player player; + + public TwoPairs(Player player) { + super("Twos", "Score of all the twos rolled."); + this.player = player; + } + + @Override + public boolean correctCategory(int[] values){ + int[] arr = new int[values.length]; + int counter = 0; + for(int i : values){ + + + } + return false; + } + + @Override + public int getScore(){ + int score = 0; + for(int i : player.getDice().getValues()){ + if( i == 2 ){ + score += i; + } + } + return score; + } +} diff --git a/Domain/Twos.java b/Domain/Twos.java new file mode 100644 index 0000000..57913bf --- /dev/null +++ b/Domain/Twos.java @@ -0,0 +1,33 @@ +package Domain; + +public class Twos extends Category{ + + private Player player; + + public Twos(Player player) { + super("Twos", "Score of all the twos rolled."); + this.player = player; + } + + @Override + public boolean correctCategory(int[] values){ + for(int i : values){ + if(i == 2){ + return true; + } + } + return false; + } + + @Override + public int getScore(){ + int score = 0; + for(int i : player.getDice().getValues()){ + if( i == 2 ){ + score += i; + } + } + return score; + } + +} diff --git a/Domain/Yatzy.java b/Domain/Yatzy.java new file mode 100644 index 0000000..894509f --- /dev/null +++ b/Domain/Yatzy.java @@ -0,0 +1,39 @@ +package Domain; + +public class Yatzy extends Category{ + + public Yatzy(Player player) { + super("Yatzy", "five times the same dice"); + } + + @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++){ + switch(i){ + 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 && five == 1){ + return true; + } + + return false; + } + + @Override + public int getScore(){ + return 75; + } +}