Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I need help with a coding problem in Java. I am trying to create a program that plays a 4 5 card game of

Hello, I need help with a coding problem in Java. I am trying to create a program that plays a 45 card game of Bulgarian Solitaire (game rules are available online if unfamiliar) using two classes. This Java program simulates the Bulgarian Solitaire game. It starts with random piles of cards taken from the original 45, removes one card from each pile, forms new piles, and continues until it reaches the goal configuration. Cards are removed and new piles are formed by distributing cards from piles to new piles by taking the last card from each non-empty pile and putting them into a new pile. If there are not enough cards in a pile, take all the cards from that pile. The goal configuration should be this array [1,2,3,4,5,6,7,8,9]. This means that the game is done. I've pasted the question below please match the sample output where updates on piles status is printed until the final array is reached thank you.
Write the code to implement the game.
You need one class that is the BulgarianSolitaire class which has the variables and methods to play a full game of Bulgarian Solitiraire.
You need another test class which will create a BulgarianSolitaire object from the above BulgarianSolitaire class and call the methods in that object to play the game.
P.S. here is a sample output, starting from 4 piles:
711234
-------------
3461022
2355921
12446820
13357719
22466718
113556717
24456816
133457715
223466814
1123557813
124467912
133568811
224577810
113466789
23556789
124456788
133456779
223456689
1123455789
1234467810
123356799
122456889
113457789
23466789
123556788
124456779
133456689
223455789
1123446789
1233567810
122456799
113456889
23457789
123466788
123556779
124456689
133455789
223446789
1123356789
1224567810
113456799
23456889
123457788
123466779
123556689
124455789
133446789
223356789
1122456789
1134567810
23456799
123456888
123457779
123466689
123555789
124446789
133356789
222456789
1113456789
234567810
123456789

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is a delta-hedge? A cross-hedge? A delta-cross-hedge?

Answered: 1 week ago

Question

Discuss whether we can control stereotyping.

Answered: 1 week ago

Question

8.10 Explain several common types of training for special purposes.

Answered: 1 week ago