Git Product home page Git Product logo

gambler's Introduction

Gambler

Lösung der folgenden Aufgabenstellung in Zusammenarbeit mit Rainier Robles und einem weiteren Kommilitonen, der nicht genannt werden will.

Für die Programmierung dieser Aufgabe definieren Sie zuerst eine Klasse Nap, die unter Anwendung der sleep-Methode der Thread-Klasse mindestens folgende statische Methoden enthält:public static void nap( int milliSekunden );public static void randomNap( int minMillisekunden, int maxMillisekunden );

Die erweiterte Aufgabe war eine Gambler Klasse zu definieren, die in der Lage ist, Glücksspieler-Objekte als Threads zu produzieren. Die Glücksspieler wetten parallel und unabhängig von einander. Alle Spieler starten mit 5 Dollar und nach jedem Spiel verlieren oder gewinnen sie einem Dollar. Die Spieler hören auf zu spielen, wenn diese kein Geld mehr haben oder sich ihr Budget verdoppelt haben. Eine Denkpause der Spieler zwischen den Wetten soll mit Hilfe der randomNap-Methode simuliert wird. Die Simulation wird beendet, wenn alle Spieler aufgehört haben zu spielen. Der gesamte Spielverlauf soll protokolliert und als Ergebnis der Simulation ausgegeben werden.

Example output:


S Nr.3 hat noch 6 Euro
S Nr.1 hat noch 6 Euro
S Nr.2 hat noch 6 Euro
S Nr.0 hat noch 4 Euro
S Nr.3 hat noch 5 Euro
S Nr.1 hat noch 5 Euro
S Nr.0 hat noch 3 Euro
S Nr.2 hat noch 7 Euro
S Nr.2 hat noch 6 Euro
S Nr.0 hat noch 4 Euro
S Nr.3 hat noch 4 Euro
S Nr.1 hat noch 4 Euro
S Nr.0 hat noch 3 Euro
S Nr.3 hat noch 5 Euro
S Nr.2 hat noch 7 Euro
S Nr.1 hat noch 5 Euro
S Nr.0 hat noch 2 Euro
S Nr.1 hat noch 6 Euro
S Nr.2 hat noch 8 Euro
S Nr.3 hat noch 6 Euro
S Nr.0 hat noch 3 Euro
S Nr.3 hat noch 7 Euro
S Nr.2 hat noch 9 Euro
S Nr.1 hat noch 7 Euro
S Nr.0 hat noch 2 Euro
S Nr.2 hat noch 10 Euro
S Nr.1 hat noch 8 Euro
S Nr.0 hat noch 3 Euro
S Nr.3 hat noch 8 Euro
S Nr.0 hat noch 2 Euro
S Nr.3 hat noch 9 Euro
S Nr.0 hat noch 1 Euro
S Nr.3 hat noch 8 Euro
S Nr.1 hat noch 7 Euro
S Nr.0 hat noch 2 Euro
S Nr.1 hat noch 8 Euro
S Nr.3 hat noch 9 Euro
S Nr.0 hat noch 1 Euro
S Nr.3 hat noch 8 Euro
S Nr.0 hat noch 0 Euro
S Nr.1 hat noch 9 Euro
S Nr.1 hat noch 8 Euro
S Nr.3 hat noch 9 Euro
S Nr.1 hat noch 9 Euro
S Nr.3 hat noch 8 Euro
S Nr.1 hat noch 8 Euro
S Nr.3 hat noch 9 Euro
S Nr.1 hat noch 7 Euro
S Nr.3 hat noch 10 Euro
S Nr.1 hat noch 6 Euro
S Nr.1 hat noch 5 Euro
S Nr.1 hat noch 6 Euro
S Nr.1 hat noch 7 Euro
S Nr.1 hat noch 6 Euro
S Nr.1 hat noch 5 Euro
S Nr.1 hat noch 6 Euro
S Nr.1 hat noch 7 Euro
S Nr.1 hat noch 6 Euro
S Nr.1 hat noch 5 Euro
S Nr.1 hat noch 6 Euro
S Nr.1 hat noch 7 Euro
S Nr.1 hat noch 8 Euro
S Nr.1 hat noch 9 Euro
S Nr.1 hat noch 8 Euro
S Nr.1 hat noch 9 Euro
S Nr.1 hat noch 8 Euro
S Nr.1 hat noch 9 Euro
S Nr.1 hat noch 8 Euro
S Nr.1 hat noch 9 Euro
S Nr.1 hat noch 10 Euro


Spieler:   S Nr.0  S Nr.1  S Nr.2  S Nr.3

Runde  0:  4           6           6           6
Runde  1:  3           5           7           5
Runde  2:  4           4           6           4
Runde  3:  3           5           7           5
Runde  4:  2           6           8           6
Runde  5:  3           7           9           7
Runde  6:  2           8           10           8
Runde  7:  3           7                       9
Runde  8:  2           8                       8
Runde  9:  1           9                       9
Runde 10:  2           8                       8
Runde 11:  1           9                       9
Runde 12:  0           8                       8
Runde 13:              7                       9
Runde 14:              6                       10
Runde 15:              5
Runde 16:              6
Runde 17:              7
Runde 18:              6
Runde 19:              5
Runde 20:              6
Runde 21:              7
Runde 22:              6
Runde 23:              5
Runde 24:              6
Runde 25:              7
Runde 26:              8
Runde 27:              9
Runde 28:              8
Runde 29:              9
Runde 30:              8
Runde 31:              9
Runde 32:              8
Runde 33:              9
Runde 34:              10

gambler's People

Contributors

chrismotian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.