diff options
| author | Stefan Suhren <suhren.stefan@fh-swf.de> | 2014-12-07 19:15:58 +0100 |
|---|---|---|
| committer | Stefan Suhren <suhren.stefan@fh-swf.de> | 2014-12-07 19:18:03 +0100 |
| commit | 9acea903216dbe371dd7b41cbf23b46a5732bcb4 (patch) | |
| tree | 5a61491ad22e470db8151d2e07f163b011c72d6e /src/de/fhswf/in/inf/java1/aufgabe7/Simulation.java | |
| parent | 8a53a8fca255e4a84ca0e35dac925a223738b98a (diff) | |
| download | Java1-9acea903216dbe371dd7b41cbf23b46a5732bcb4.tar.gz Java1-9acea903216dbe371dd7b41cbf23b46a5732bcb4.zip | |
Refactored the packagenames fo better sorting
Diffstat (limited to 'src/de/fhswf/in/inf/java1/aufgabe7/Simulation.java')
| -rw-r--r-- | src/de/fhswf/in/inf/java1/aufgabe7/Simulation.java | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/src/de/fhswf/in/inf/java1/aufgabe7/Simulation.java b/src/de/fhswf/in/inf/java1/aufgabe7/Simulation.java deleted file mode 100644 index 71e23a0..0000000 --- a/src/de/fhswf/in/inf/java1/aufgabe7/Simulation.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * - */ -package de.fhswf.in.inf.java1.aufgabe7; - -/** - * Calculates the the success rate of different players. - * - * @author $Author: $ - * @version $Revision: $, $Date: $ UTC - */ -public final class Simulation -{ - - private static final int VERSUCHE = 100000; - - /** - * Prevents instantiation of the utility class. - * - */ - private Simulation() - { - } - - /** - * Makes anzahl games. - * - * @param anzahl - * How often the game will be run. - * @return Victory count - */ - private static int nDurchlaufeAusfuehren(Spiel spiel, Spieler spieler, - int anzahl) - { - - int erfolge = 0; - for (int i = 0; i < anzahl; i++) - { - if (spiel.spielDurchlauf(spieler)) - { - erfolge++; - } - } - - return erfolge; - } - - /** - * Calculates the success rate of every player. - * - * @param erfolg - * An array with the last game stats. - */ - private static double wahrscheinlichkeitErrechnen(int erfolge, int versuche) - { - return (double) erfolge / versuche; - } - - /** - * Main method of the package. - * - * @param args - * Command line arguments - */ - public static void main(String[] args) - { - - Spieler[] spieler = {new GleichSpieler(), new WechselSpieler(), - new ZufallsSpieler(0.5)}; - - Spiel spiel = new Spiel(); - - for (int i = 0; i < spieler.length; i++) - { - int spielerGewinne = nDurchlaufeAusfuehren(spiel, spieler[i], - VERSUCHE); - double spielerProb = wahrscheinlichkeitErrechnen(spielerGewinne, - VERSUCHE); - System.out.printf("%17s war %05.2f%s erfolgreich\n", spieler[i] - .getClass().getSimpleName(), spielerProb * 100, "%"); - } - } - -} |
