main
Jens 2024-05-03 21:44:06 +02:00
parent 008ea79ce2
commit 7e803d7a56
3 changed files with 144 additions and 20 deletions

View File

@ -1,5 +1,57 @@
package Domain;
public class FourPairs {
public class FourPairs extends Category{
private Player player;
private int one = 0, two = 0, three = 0, four = 0, five = 0;
public FourPairs(Player player) {
super("Four Pairs", "Four times the same dice");
this.player = player;
}
@Override
public boolean correctCategory(int[] values){
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 == 4 || two == 4 || three == 4 || four == 4 || five == 4){
return true;
}
return false;
}
@Override
public int getScore(){
if(one == 4){
return 4;
}
else if(two == 4){
return 8;
}
else if(three == 4){
return 12;
}
else if(four == 4){
return 16;
}
else if(five == 4){
return 20;
}
return 0;
}
}

View File

@ -2,9 +2,56 @@ package Domain;
public class ThreePairs extends Category{
public ThreePairs(String name, String description) {
super(name, description);
//TODO Auto-generated constructor stub
private int one = 0, two = 0, three = 0, four = 0, five = 0;
public ThreePairs(Player player) {
super("Three Pairs", "Three times the same dice");
}
@Override
public boolean correctCategory(int[] values){
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){
return true;
}
return false;
}
@Override
public int getScore(){
if(one == 4){
return 4;
}
else if(two == 4){
return 8;
}
else if(three == 4){
return 12;
}
else if(four == 4){
return 16;
}
else if(five == 4){
return 20;
}
return 0;
}
}

View File

@ -2,32 +2,57 @@ package Domain;
public class TwoPairs extends Category{
private Player player;
private int one = 0, two = 0, three = 0, four = 0, five = 0;
public TwoPairs(Player player) {
super("Twos", "Score of all the twos rolled.");
this.player = player;
super("Two Pairs", "Two times the same dice");
}
//Weitere methode einfügen falls mehrere paare vorhanden sind
@Override
public boolean correctCategory(int[] values){
int[] arr = new int[values.length];
int counter = 0;
for(int i : values){
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 == 2 || two == 2 || three == 2 || four == 2 || five == 2){
return true;
}
return false;
}
@Override
public int getScore(){
int score = 0;
for(int i : player.getDice().getValues()){
if( i == 2 ){
score += i;
if(one == 2){
return 2;
}
else if(two == 2){
return 4;
}
return score;
else if(three == 2){
return 16;
}
else if(four == 2){
return 8;
}
else if(five == 2){
return 10;
}
return 0;
}
}