-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExample9.java
More file actions
37 lines (28 loc) · 772 Bytes
/
Example9.java
File metadata and controls
37 lines (28 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package applications.algorithms;
import datastructs.adt.ArrayStack;
/**
* Demonstrates how to use stacks to solve the
* Towers of Hanoi problem
*/
public class Example9 {
public class Disk
{
int size = 0;
Disk(int size)
{
this.size = size;
}
}
public static void run(String[] args){
Example9 game = new Example9();
ArrayStack<Disk> peg1 = new ArrayStack<Disk>(10);
for(int i=0; i< peg1.capacity(); ++i){
peg1.push(game.new Disk(peg1.capacity() - i));
}
ArrayStack<Disk> peg2 = new ArrayStack<Disk>(10);
ArrayStack<Disk> peg3 = new ArrayStack<Disk>(10);
}
public static void main(String[] args){
Example9.run(args);
}
}