| 32 | } |
| 33 | |
| 34 | public void moveDisks(int n, Tower destination, Tower buffer){ |
| 35 | if (n > 0) { |
| 36 | String tag = "move_" + n + "_disks_from_" + this.index + "_to_" + destination.index + "_with_buffer_" + buffer.index; |
| 37 | System.out.println("<" + tag + ">"); |
| 38 | moveDisks(n - 1, buffer, destination); |
| 39 | System.out.println("<move_top_from_" + this.index + "_to_" + destination.index + ">"); |
| 40 | System.out.println("<before>"); |
| 41 | System.out.println("<source_print>"); |
| 42 | this.print(); |
| 43 | System.out.println("</source_print>"); |
| 44 | System.out.println("<destination_print>"); |
| 45 | destination.print(); |
| 46 | System.out.println("</destination_print>"); |
| 47 | System.out.println("</before>"); |
| 48 | moveTopTo(destination); |
| 49 | System.out.println("<after>"); |
| 50 | System.out.println("<source_print>"); |
| 51 | this.print(); |
| 52 | System.out.println("</source_print>"); |
| 53 | System.out.println("<destination_print>"); |
| 54 | destination.print(); |
| 55 | System.out.println("</destination_print>"); |
| 56 | System.out.println("</after>"); |
| 57 | System.out.println("</move_top_from_" + this.index + "_to_" + destination.index + ">"); |
| 58 | buffer.moveDisks(n - 1, destination, this); |
| 59 | System.out.println("</" + tag + ">"); |
| 60 | } |
| 61 | } |
| 62 | } |