First Upadate

main
Jens 2024-05-03 21:10:44 +02:00
parent 711659d67b
commit 008ea79ce2
15 changed files with 409 additions and 4 deletions

View File

@ -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;
}
}

32
Domain/Fives.java 100644
View File

@ -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;
}
}

View File

@ -0,0 +1,5 @@
package Domain;
public class FourPairs {
}

32
Domain/Fours.java 100644
View File

@ -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;
}
}

View File

@ -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;
}
}

33
Domain/Ones.java 100644
View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

32
Domain/Sixes.java 100644
View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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
}
}

32
Domain/Threes.java 100644
View File

@ -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;
}
}

View File

@ -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;
}
}

33
Domain/Twos.java 100644
View File

@ -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;
}
}

39
Domain/Yatzy.java 100644
View File

@ -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;
}
}