![]() ![]() ![]() The states that you will need are PegFirstClickState, PegSecondClickState, and PegGameOverState. Remember that this design pattern requires a two-way has-a relationship. Use the state design pattern to complete Pegs.java. ![]() The states that you will be writing will implement this interface. The only method in this interface is mouseClicked. What the states have in common is that they are all activated on mouse click. The next click will start a new gane with the clicked-on location as the open spot. Game Over: There are no more legal jumps (the game is over). Second Click: A clicked on peg has two possible jumps, so two mouse clicks are required to execute the jump. Triangle Peg Solitaire has three distinct states.įirst Click: A clicked on peg has only one possible jump, so take that jump. Interfaces Dynamic Chageability Two-Way Has-A State Design Pattern TrianglePegSolitaire.zip PegState.java Pegs.java PegFirstClickState.java PegSecondClickState.java The green peg (after the first jump) is a peg that can be used to find the optimal solution (fewest pegs left at the end) from the current board configuration. Purple pegs are pegs that curently can jump over at least one other peg. Red pegs are pegs that currently cannot jump over any other pegs. The goal is to have only one peg remaining at the end. You can only jump over the nearest neighbor pegs. You remove pegs one at a time by jumping over other pegs to empty slots. This location can be anywhere on the board, but it is usually the bottom-middle spot. There is one location that does not have a peg in it. SOLVED: Triangle Peg Solitaire is a game where you start with several pegs at fixed locations on a triangular board. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |