Description: My old friend Becky taught me a form of patience (solitaire) that I would like to be able to play on the computer. It is very simple, so really needs no graphics but, for fun, I will give you classes to do that as well.

This is how it works:

  • The object of the game is to end up with one pile of cards. I have never succeeded in that.
  • Shuffle a deck of cards
  • Lay down the first card face up
  • Lay down the next one next to it, and so on
  • This would lead you to 52 cards all facing upwards, except that you can put one pile on another if any of the following apply:
    • They are next to each other and the same number or suit
    • There are 2 piles between them and they are the same number or suit

Here is an example (H is hearts etc. The new card dealt is in bold): See image.

Sometimes you can amalgamate piles in the middle:

3H 4D 7C 8S 3D becomes 3H 3D 7C 8S and then 3D 7C 8S (think about it)

Your game should have a menu that allows you to:

  • Shuffle
  • Show the pack (this is so you can check that it plays properly)
  • Deal a card
  • Make a move, move last pile onto previous one
  • Make a move, move last pile back over 2 piles
  • Amalgamate piles in the middle (by giving their numbers)
  • Play for me (if 2 possible moves, makes the ‘furthest’ one)
  • Quit

You should save a little file of low scores – the score is the number of piles left at the end of the game. When the person is finished playing you should give them the opportunity to submit their score to that file if appropriate.

Strong hints

MAKE SURE YOU DO THIS A BIT AT A TIME!!!! Test each class and function as you develop it – never get too far from a working application. The first 3 requirements should be working before you attempt to support the playing the basic game requirements. You may never get to the ‘amalgamate piles’, ‘play for me’ or ‘high score’ requirements. If you do a good job on the rest of it you will still do OK.

Your code should demonstrate use of ArrayLists, a do..while loop, catching exceptions, reading from and writing to a text file, checking errors (for instance illegal moves). It should have good Javadoc comments and appropriate algorithms.

I have provided a file with the ‘card’ information in it. Read it in to get a ‘pack’.

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.