package interfaceExample; public class Dog implements Animal { private int burriedBonesCount; private String animalName; public Dog(String nameIn) { animalName = nameIn; burriedBonesCount = 0; } public String getName() { return animalName; } public void setName(String nameIn) { animalName = nameIn; } public String makeSound() { return "woof"; } public String toString() { return animalName; } public void buryBone() { burriedBonesCount++; } public int howManyBones() { return burriedBonesCount; } public boolean equals (Object other) { //Consider what happens if a non-Dog object // were to be passed in with the following. if (other == null) { return false; } else if (this.getClass()!=other.getClass()) { return false; } else { Dog casted = (Dog)other; return ( (animalName.equals(casted.animalName)) && (burriedBonesCount == casted.burriedBonesCount) ); } } } //Copyright 2010-2016 : Evan Golub