Code Monkey home page Code Monkey logo

simple-poker's Introduction

Simple-Poker (Java)

One player simple poker, gives you a hand, option to draw a new card, and then evaluates your hand.

HOW TO USE:

Run the program, and it'll show you your cards and ask you to keep or redraw each one. After you do that, it will display your new hand and tell you its evaluation. Then you will be prompted to play again.

To test the program, use the makeHand() method in the Game class. You can use it to set each card's rank and suit. You also must uncomment "this.makeHand();" in the play() method.

GameTest class:

This class instantiates the Game class and calls game.play().

Game class:

This class is responsible for instantiating the Deck and PLayer classes It calls methods in Deck to fill and shuffle it, and then calls a method in Player to draw from the Deck. The hand is sorted and then it prompts redraws. Then the hand is sorted again before it is evaluated, to make evaluation easier. The evaluate() method evaluates the hand, starting from royal flush all the way down to highest card. Then the user is asked if they want to play again.

Card class:

The Card class keeps track of the suit and rank of each card. It also has a compareTo class so that I can use Arrays.sort() to sort the hand.

Player class:

The Player class has two methods. One is a draw method which returns the hand, and the other is a redraw method which returns the next card the deck.

Deck class:

The Deck class is responsible for filling the deck with 52 Card objects. It shuffles by taking two random numbers from the size of the deck and switching those two card. It does this 2000 times, but it can be changed by changing SHUFFLE_EXCHANGES in the constructor. Method deal() returns a hand of 5 cards. redeal() returns the next card in the deck. The position of the counter must be refreshed everytime the deck is redealed, solved by refreshDeckPosition().

simple-poker's People

Contributors

andyxhadji 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.