package towerofhanoi;
import java.awt.Color;
import java.util.Random;
import CS2114.Shape;
// 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 Disk extends Shape implements Comparable<Shape> {
/**
* Disk constructor
*
* @param width
* - width of the disk
*/
public Disk(int width) {
super(0, 0, width, PuzzleWindow.DISK_HEIGHT);
Random gen = new Random();
Color newColor = new Color(gen.nextInt(226), gen.nextInt(226), gen
.nextInt(226));
this.setBackgroundColor(newColor);
}
/**
* @param otherDisk
* - the shape you are comparing
* @return an integer signifying whether or not the two objects are equal
*/
public int compareTo(Shape otherDisk) {
if (otherDisk == null) {
throw new IllegalArgumentException();
}
if ((this.getWidth() - otherDisk.getWidth()) > 0) {
return 1;
}
if ((this.getWidth() - otherDisk.getWidth()) < 0) {
return -1;
}
return 0;
}
/**
*
* @param otherDisk
* - the disk being compared
* @return if the width of the disks are equal
*/
public boolean equals(Object otherDisk) {
if (this == otherDisk) {
return true;
}
if ((otherDisk != null) && (otherDisk.getClass() == Disk.class)) {
return this.compareTo((Disk) otherDisk) == 0;
}
return false;
}
/**
* toString method
*
* @return the width as a string
*/
public String toString() {
return String.valueOf(this.getWidth());
}
}