Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Triangle Pe Solitaire is a game where you start with several pegs at fixed locations on a triangular board. There is one location that does

image text in transcribed

Triangle Pe Solitaire is a game where you start with several pegs at fixed locations on a triangular board. There is one location that does not have a peg in it. This location can be anywhere on the board, but it is usually the bottom-middle spot. You remove pegs one at a time by jumping over other pegs to empty slots, removing the jumped pegs from the board. You can only jump over the nearest neighbor pegs. The goal is to have only one peg remaining at the end. .Red pegs are pegs that crently cannot jump over any other pegs. Puple pegs are pegs that crently can jump over at least one other peg. 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 contiguration. Starting Files: lePegSolitaire. PegState.java Pegs.java .PegSecondClickState java Lab: . Interfaces Dynamic Chageability Two-Way Has-A State Design Pattem Part I: Peg State Triangle Peg Solitaire has three distinct states. First Click: A clicked on peg has only one possible jmp, so take thatjp Second Click: A clicked on peg has two possible jumps, so two mouse clicks are required to execute the jmmp Gane Over: There are no more legal jumps (the game is over). The next click will start a new gae with the clicked-on location as the open spot . What the states have in common is that they are all activated on a mouse cick. Take a look at PegState.ava The only method in this interface is mouseClicked. The states that you will be writing will implement this interface. Part II: Pegs Use the state design pattern to complete Pegs.java. Remember that this design pattern requires a two-way has-a relationship. The states that you will need are PegFirstClickState. PegSecondClickState and PegGameOverState. Note that Pegs has methods to determine ifa peg has been clicked on or ifan open slot has been clicked on. You will need both of these! Part III: The States Complete the three states. You will need to call methods on Pegs java. For PegGameoverState (write from scratch), the mouseClicked method looks for the clickad-on slot. This slot becomes the open space for the new game. An invalid click stays in PegGameOverState. The main method is in the TrianglePegSolitaire class. Triangle Pe Solitaire is a game where you start with several pegs at fixed locations on a triangular board. There is one location that does not have a peg in it. This location can be anywhere on the board, but it is usually the bottom-middle spot. You remove pegs one at a time by jumping over other pegs to empty slots, removing the jumped pegs from the board. You can only jump over the nearest neighbor pegs. The goal is to have only one peg remaining at the end. .Red pegs are pegs that crently cannot jump over any other pegs. Puple pegs are pegs that crently can jump over at least one other peg. 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 contiguration. Starting Files: lePegSolitaire. PegState.java Pegs.java .PegSecondClickState java Lab: . Interfaces Dynamic Chageability Two-Way Has-A State Design Pattem Part I: Peg State Triangle Peg Solitaire has three distinct states. First Click: A clicked on peg has only one possible jmp, so take thatjp Second Click: A clicked on peg has two possible jumps, so two mouse clicks are required to execute the jmmp Gane Over: There are no more legal jumps (the game is over). The next click will start a new gae with the clicked-on location as the open spot . What the states have in common is that they are all activated on a mouse cick. Take a look at PegState.ava The only method in this interface is mouseClicked. The states that you will be writing will implement this interface. Part II: Pegs Use the state design pattern to complete Pegs.java. Remember that this design pattern requires a two-way has-a relationship. The states that you will need are PegFirstClickState. PegSecondClickState and PegGameOverState. Note that Pegs has methods to determine ifa peg has been clicked on or ifan open slot has been clicked on. You will need both of these! Part III: The States Complete the three states. You will need to call methods on Pegs java. For PegGameoverState (write from scratch), the mouseClicked method looks for the clickad-on slot. This slot becomes the open space for the new game. An invalid click stays in PegGameOverState. The main method is in the TrianglePegSolitaire class

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

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

More Books

Students also viewed these Databases questions

Question

dy dx Find the derivative of the function y=(4x+3)5(2x+1)2.

Answered: 1 week ago

Question

Draw and explain the operation of LVDT for pressure measurement

Answered: 1 week ago

Question

5. What are the main groups without health insurance? LO24.3

Answered: 1 week ago