nCS 226 Homework 4 Programming : Due Monday Febrary 26. For this assignment, you will implement the towers of Hanoi problem using a stack structure implemented with a singly linked list. The towers of Hanoi is described in problem C-3.11 of the book. You will implement the solution in the following stages. 1. You will implement the LinkedStack data structure as described in the book. 2. With this stack, you will implement a Tower datatype that implements the basic operations of the tower of Hanoi problem. In particular, each pole operates like a stack, so it is a natural extension of the stack structure. Note it is specialized to Integers, and also that it has a "toString" method so that you can print the contents of the Stack. The latter will may require a little creative thinking on your part as to how to run through the stack so that you can print the elements without disturbing the ordering. A good definition for a tower class (minus methods) would be: abstract class Tower extends LinkedStack { // create a tower of size n public Tower(int n); // Take the top element from a tower public Integer remove(); // Put an element on a tower. Throw and exception if // the element is out of order public void place(Integer o) throws OutOfOrderException; // Query the top element. Integer top(); // Create a printable representation of a tower public String toString(); } 3. Write a main program that solves the tower problem of size 4. The program should create three Towers, one of which is populated with 4 disks numbered 1-4. It should then move the entire stack from Tower one Tower to another while guaranteeing that there is never a disk larger disk on top of a smaller one. Each move should be printed out as it is performed. The stacks should also be printed at the beginning and end of the program. Here is the output of my program: java towers Starting Configuration 1 2 3 4 --- Tower 0 | | | | --- Tower 1 | | | | --- Tower 2 Moving 1 from 0 to 2 Moving 2 from 0 to 1 Moving 1 from 2 to 1 Moving 3 from 0 to 2 Moving 1 from 1 to 0 Moving 2 from 1 to 2 Moving 1 from 0 to 2 Moving 4 from 0 to 1 Moving 1 from 2 to 1 Moving 2 from 2 to 0 Moving 1 from 1 to 0 Moving 3 from 2 to 1 Moving 1 from 0 to 2 Moving 2 from 0 to 1 Moving 1 from 2 to 1 Ending Configuration | | | | --- Tower 0 1 2 3 4 --- Tower 1 | | | | --- Tower 2 4. Extra credit (10 pts): Make the towers graphical objects and display the solution graphically. TO SUBMIT: Please submit a zipped or tarred folder that contains your source code. The main program should be in a file called 'towers.java'.