Jens 2024-05-03 12:22:01 +02:00
parent 82a53c4120
commit 711659d67b
5 changed files with 99 additions and 38 deletions

View File

@ -0,0 +1,36 @@
package Domain;
public class Category {
private String name;
private String description;
private boolean scored;
private int score;
public Category(String name, String description, boolean scored, int score){
this.name = name;
this.description = description;
this.scored = false;
this.score = score;
}
public String getName(){
return name;
}
public String getDescription(){
return description;
}
public boolean isScored(){
return scored;
}
public int getScore(){
return score;
}
public boolean correctCategory(){
return true;
}
}

View File

@ -4,18 +4,30 @@ import java.util.Random;
public class Dice {
private int numberOfDice;
private int[] values;
private Random random;
public Dice(int numberOfDice){
this.numberOfDice = numberOfDice;
this.values = new int[5];
this.random = new Random();
}
public int rollDice(int numberOfDice){
Random random = new Random();
numberOfDice = random.nextInt(6);
return numberOfDice + 1;
public void rollDice(int numberOfDice){
for(int i = 0; i < values.length; i++){
values[i] = random.nextInt(6) + 1;
}
}
public int getAugenzahl(){
return numberOfDice;
}
public int getValue(int index){
return values[index];
}
public int[] getValues(){
return values;
}
}

View File

@ -3,41 +3,19 @@ package Domain;
public class Player {
private String name;
private int[] tabelle;
private Yatzy_Sheet sheet;
public Player(String name){
public Player(String name, Yatzy_Sheet sheet){
this.name = name;
this.tabelle = new int[17];
}
//counts all the
public int getSumOne(){
int sum = 0;
for(int i = 0; i < 6; i++){
sum += tabelle[i];
}
return sum;
}
public int getSumTwo(){
int sum = 0;
for (int i = 7; i < 17; i++){
sum += tabelle[i];
}
return sum;
}
public int getSum(){
int sumOne = getSumOne();
int sumTwo = getSumTwo();
return sumOne += sumTwo;
}
public String toString(){
for (int i = 0; i < )
this.sheet = sheet;
}
public String getName(){
return name;
}
public Yatzy_Sheet getSheet(){
return sheet;
}
}

View File

@ -0,0 +1,27 @@
package Domain;
public class Yatzy_Sheet {
private int[] tabelle;
//counts all the
public int getSumOne(){
int sum = 0;
for(int i = 0; i < 6; i++){
sum += tabelle[i];
}
return sum;
}
public int getSumTwo(){
int sum = 0;
for (int i = 7; i < 17; i++){
sum += tabelle[i];
}
return sum;
}
public int getSum(){
int sumOne = getSumOne();
int sumTwo = getSumTwo();
return sumOne += sumTwo;
}
}

View File

@ -13,9 +13,17 @@ public class Game {
return 0;
}
public Player newPlayer(){
Player p1 = new Player("Jens");
player.add(p1);
return p1;
public ArrayList<Player> newPlayer(int playerCount, String name){
for(int i = 0; i < playerCount; i++){
Player p1 = new Player(name, null);
player.add(p1);
}
return player;
}
public int showScore(){
Player secondPlayer = player.get(1);
return secondPlayer.getSheet();
}
}