Code Monkey home page Code Monkey logo

java-training-exercices's Introduction

hands

This is a Java exercice about finding the correct pker Hands in 5 cards.

The package contains :

  • Some starting code describing domain objects
  • Some Interfaces explaining what business code should do
    • mostly about organizing and sorting hands
  • All the needed Unit test

So the trainee must read the unit tests, and implement the business code so that the test passes. It's designed for Java beginners, so there are a lot of small steps and it's well guided

Card colors

  • s for spade: ♠️
  • d for diamond: ♦️
  • h for heart: ♥️
  • c for club: ♣️

Ah is the Ace of Heart

Where to start ?

You must pass the tests in that exact order:

  • DeckGeneratotTest
  • DeckTest
  • HandTest

The map

The group() map will allow to build a nice map for your algorithm.

Let's say you have: 2c 4s 4h Ah Ad

Key Value
2 [ 2c]
4 [ 4s, 4h]
14 [ Ah, Ad]

Remember that this is a TreeMap, keys are ordered. So you have map.size() == 3. It proves that your hand is either a Double Pair or a Trips

Let's say you have: 2c 4s 4h 4d Ad

Key Value
2 [ 2c]
4 [ 4s, 4h, 4d]
14 [ Ad]

You also have map.size() == 3.

So your algorithm must find difference between Double Pair and Trips. The Hand class has a number(cardValue) method for this.

If you have map.size()==3 && hand.number(map.keySet().first()) ==3 then you have a trips.

java-training-exercices's People

Contributors

hylrac avatar nicolas-zozol avatar zittersteijnmichiel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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