package towerofhanoi;
// Virginia Tech Honor Code Pledge:
//
// As a Hokie, I will conduct myself with honor and integrity at all times.
// I will not lie, cheat, or steal, nor will I accept the actions of those who
// do.
// -- Jordan Harrington (jordanha23)
/**
* @author Jordan Harrington
* @version <3/25/2020>
*/
public class Tower extends LinkedStack<Disk> {
private Position position;
/**
* Constructor
*
* @param position
* - the position of the tower
*/
public Tower(Position position) {
super();
this.position = position;
}
/**
* Getter for position
*
* @return the position of the tower
*/
public Position position() {
return position;
}
@Override
/**
* @param disk
* - the disk being pushed on the tower
*/
public void push(Disk disk) {
if (disk == null) {
throw new IllegalArgumentException();
}
else if (this.isEmpty()) {
super.push(disk);
}
else if (this.peek().compareTo(disk) != 1) {
throw new IllegalStateException();
}
else {
super.push(disk);
}
}
}