MCPcopy Index your code
hub / github.com/careercup/ctci / moveDisks

Method moveDisks

java/Chapter 3/Question3_4/Tower.java:34–61  ·  view source on GitHub ↗
(int n, Tower destination, Tower buffer)

Source from the content-addressed store, hash-verified

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}

Callers 1

mainMethod · 0.80

Calls 2

printMethod · 0.95
moveTopToMethod · 0.95

Tested by

no test coverage detected