Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lesson2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ru.geekbrains;

public class lesson2 {
public static void main(String[] args) {
lesson2Steps.moveTower(3, 'A', 'B', 'C');
}
}
16 changes: 16 additions & 0 deletions lesson2Steps.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ru.geekbrains;

public class lesson2Steps {
static void move(char point1, char point2) {
System.out.println("Передвигаем из стержня " + point1 + " в стержень " + point2);
}

static void moveTower(int amount, char point1, char point2, char temp) {
if (amount == 0) {
return;
}
moveTower(amount - 1, point1, temp, point2);
move(point1, point2);
moveTower(amount - 1, temp, point2, point1);
}
}