I am getting this error message:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: Pet.saySomething at PetTest.main(PetTest.java:18) Java Result: 1
Here is what i have: for the Speak
class,
public class Speak { public void saySomething(); }
Here is what i have in the PetTest
class:
import java.util.ArrayList; public class PetTest { public static void main(String[] args) { ArrayList<Pet> myPets = new ArrayList<Pet>(); myPets.add(new Parrot("Boss")); myPets.add(new Cat("Oreo")); myPets.add(new Dog("Riley")); for (Pet p: myPets) { p.saySomething(); System.out.println(p); } } }
I did not post the other 5 classes that go with this program. I know there is something that needs to be fixed in the Speak
class, but i am stuck. In the Speak
class, on the line that says public void saySomething();
it says Missing Method body, or declare abstract.
EDIT: Here are the other classes:
public abstract class Pet { String name; public Pet(String name){ this.name = name; } } public class Parrot extends Bird { public Parrot (String name) { super(name); } @Override public void saySomething() { System.out.println("Pauly want a craker?"); } @Override public String toString() { return "Hello, I'm " + name + " the parrot."; } } public class Dog extends Pet { public Dog (String name) { super(name); } @Override public void saySomething() { System.out.println("Ruff, ruff!"); } @Override public String toString() { return "Hello, I'm " + name + " the dog."; } } public class Cat extends Pet { public Cat(String name) { super(name); } @Override public void saySomething() { System.out.println("Meow."); } @Override public String toString() { return "Hello, I'm " + name + " the cat."; } } public class Bird extends Pet { public Bird(String name) { super(name); } public void saySomething(){} }