started 2025ft
This commit is contained in:
36
src/j2025/FT/PairOfDice.java
Normal file
36
src/j2025/FT/PairOfDice.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package j2025.FT;
|
||||
|
||||
public class PairOfDice implements Comparable<PairOfDice> {
|
||||
|
||||
private final Die die1;
|
||||
private final Die die2;
|
||||
|
||||
public PairOfDice(Die die1, Die die2) {
|
||||
this.die1 = die1;
|
||||
this.die2 = die2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(PairOfDice other) {
|
||||
return Integer.compare(this.getValue(), other.getValue());
|
||||
}
|
||||
|
||||
private int getValue() {
|
||||
int high = Math.max(die1.ordinal(), die2.ordinal());
|
||||
int low = Math.min(die1.ordinal(), die2.ordinal());
|
||||
|
||||
// Mäxchen (2,1) → höchster Wert
|
||||
if (high == 2 && low == 1) return Integer.MAX_VALUE;
|
||||
|
||||
// Pasch → 100 + Augenzahl (11..66 → 101..106)
|
||||
if (high == low) return 100 + high;
|
||||
|
||||
// Normale Würfe → zweistellige Zahl (z.B. 6,5 → 65)
|
||||
return high * 10 + low;
|
||||
}
|
||||
|
||||
public static PairOfDice random() {
|
||||
return new PairOfDice(Die.random(), Die.random());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user