Ok so I'm having trouble with getting a portion of my code to work. I'm trying to creat an object but I can't because I keep getting "Dog is not abstract and does not override abstract method setName(String) in Nameable" Below is my code that I'm using for this part
Nameable.javaCode
package blah.blah.zoo;
public interface Nameable {
String getName();
void setName(String name);
}
Animal.javaCode
package blah.blah.zoo;
public abstract class Animal implements Nameable{
private String name;
private int numLegs, age, numOfAnimals=0;
public Animal(String name, int numLegs, int age){
this.name = name;
this.numLegs = numLegs;
this.age = age;
numOfAnimals++;
}
public String getName(){
return name;
}
public int getNumLegs(){
return numLegs;
}
public int getAge(){
return age;
}
public int numOfAnimals(){
return numOfAnimals;
}
public String toString(){
return "Animal Object: [name=" + name + " , age=" + age + " , numLegs=" + numLegs + "]";
}
}
Dog.javaCode
package blah.blah.zoo;
public class Dog extends Animal{
public Dog(String name, int numLegs, int age){
super(name, numLegs, age);
}
}
Lastly, my test file test.javaCode
package blah.blah.zoo;
public class test{
public static void main(String[] args){
Dog ABC = new Dog("John", 4, 12);
//System.out.println(ABC.getName());
}
}
If someone could point me in the right direction with figuring out what I need to add/change that would be great. I'm having a hard time understanding the purpose of Nameable.java
This post was edited by ice060788 on Sep 15 2016 12:38am