Question: I need help creating a game using java that utilizes the Tower of Hanoi Puzzle, I need the following: A Disc class, A pole class,

I need help creating a game using java that utilizes the Tower of Hanoi Puzzle, I need the following: A Disc class, A pole class, A TowerOfHanoi class, and a TowerOfHanoiPuzzle class

PLEASE: write code following the output below, THANK YOU

1. Ask a user whether he/she wants to play the Tower of Hanoi puzzle or exit as shown below:

Welcome to Tower of Hanoi Puzzle

Take a pick:

1) Play a Tower of Hanoi Puzzle

2) Exit

If the user pick 2, simply exit the program. If the user pick 1, continue. However, if the user

enter another number other than 1 and 2, simply ask again.

2. Ask a user how many disk he/she wants to play as shown below:

How many disks would you like to play (between 1 and 64): 4

Note that if the user enter a number that is out-of-range (less than 1 or greater than 64),

simply ask again.

3. Construct a Tower of Hanoi object where the maximum number of disks and the maximum

disk size of each pole is the same as the number of disks the user wants to play

4. Show the tower of Hanoi on the screen with all disks are neatly stacked into the first pole.

Also show the goal of the puzzle including the least number of possible moves and ask the

user whether he/she is ready to play. The following is an example of the Tower of Hanoi

puzzle with 4 disks:

*|* | |

**|** | |

***|*** | |

****|**** | |

=============================

The goal is to move all 4 disks from pole 1 to pole 3 The least number of moves for 4 disks is 15. Are you ready to play? (y/n):

*|* | |

**|** | |

***|*** | |

****|**** | |

=============================

Number of Moves: 0

Enter to move a disk:

where is a pole number (1, 2, or 3) and is a pole number. If a user enter 0 0

( is 0 and is also 0), simply go back to the main menu.

If user enter 1 3 (move the top disk from the pole number 1 to the pole number 3), your

program should show the current puzzle, number of moves, and ask again as shown below:

Enter to move a disk: 1 3

| | |

**|** | |

***|*** | |

****|**** | *|*

=============================

Do not forget that a user is not allowed to put larger disk on top of the smaller one. So, if the user enter 1 3 again, here is the result:

You cannot move the top disk from pole 1 to pole 3. The top disk of pole 1 is larger than the top disk of pole 3.

| | |

**|** | |

***|*** | |

****|**** | *|*

=============================

Number of Moves: 2 Enter to move a disk:

Note that the number of moves should be increased as well even though the user made a

mistake.

There is also a chance that the user enter something that is invalid. For example, the user

may enter 1 4.

6. Lastly, if a user is able to move all disks from pole 1 to pole 3, simply congratulate the user

with his/her number of moves compared to the least number of moves as shown below:

| | *|*

| | **|**

| | ***|***

| | ****|****

=============================

Congratulation!!!

Number of Moves: 15

The least number of moves for 4 disks is 15.

Welcome to Tower of Hanoi Puzzle(repeating program)

For this project, you have to submit the following files:

Disk.java

Pole.java

TowerOfHanoi.java

TowerOfHanoiPuzzle.java

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!