summaryrefslogtreecommitdiffstats
path: root/src/de/fhswf/in/inf/java1/aufgabe7/Spieler.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/fhswf/in/inf/java1/aufgabe7/Spieler.java')
-rw-r--r--src/de/fhswf/in/inf/java1/aufgabe7/Spieler.java52
1 files changed, 10 insertions, 42 deletions
diff --git a/src/de/fhswf/in/inf/java1/aufgabe7/Spieler.java b/src/de/fhswf/in/inf/java1/aufgabe7/Spieler.java
index 23f2e7c..40c7254 100644
--- a/src/de/fhswf/in/inf/java1/aufgabe7/Spieler.java
+++ b/src/de/fhswf/in/inf/java1/aufgabe7/Spieler.java
@@ -3,52 +3,35 @@
*/
package de.fhswf.in.inf.java1.aufgabe7;
-import java.util.Random;
-
/**
* Represents a player that chooses a shell.
*
* @author $Author: $
* @version $Revision: $, $Date: $ UTC
*/
-public class Spieler
+public abstract class Spieler
{
- private Random rnd = new Random();
private int ersterTipp = -1;
- private int wahrscheinlichkeit = 0;
-
- private boolean nutztWechselStrategy = false;
-
/**
- * A player with a certain probability of switching its strategy.
+ * The first shell the player chooses.
*
- * @param nutztWechselStrategy
- * Choose initial strategy.
- * @param wahrscheinlichkeit
- * The probability of switching strategy.
+ * @return The first guess for a shell
*/
- public Spieler(boolean nutztWechselStrategy, int wahrscheinlichkeit)
+ public final int ersterTipp()
{
- if (wahrscheinlichkeit < 0 | wahrscheinlichkeit > 100)
- {
- throw new IllegalArgumentException(
- "Only a probability between 0 and 100 is allowed.");
- }
-
- this.wahrscheinlichkeit = wahrscheinlichkeit;
- this.nutztWechselStrategy = nutztWechselStrategy;
+ ersterTipp = Spiel.RAND.nextInt(Spiel.MAXHUET);
+ return ersterTipp;
}
/**
- * The first shell the player chooses.
+ * Getter for the first choice.
*
- * @return The first guess for a shell
+ * @return The first choice
*/
- public int ersterTipp()
+ public final int getErsterTipp()
{
- ersterTipp = rnd.nextInt(Spiel.MAXHUET);
return ersterTipp;
}
@@ -59,21 +42,6 @@ public class Spieler
* The shell, the game showed as empty
* @return The second guess for the right shell
*/
- public int zweiterTipp(int leeresHuetchen)
- {
- if (rnd.nextInt(100) < wahrscheinlichkeit)
- {
- nutztWechselStrategy = !nutztWechselStrategy;
- }
-
- if (nutztWechselStrategy)
- {
- return Spiel.MAXHUET - ersterTipp - leeresHuetchen;
- }
- else
- {
- return ersterTipp;
- }
- }
+ public abstract int zweiterTipp(int leeresHuetchen);
}