Name: Anonymous 2011-02-18 23:29
Can't figure out how to fix this Java error.
Abstract Pet Class:
Cat Sub-Class:
Error:
Error(3,8): homework2.Cat is not abstract and does not override abstract method compareTo(java.lang.Object) in java.lang.Comparable
What am I doing wrong? The only relevant detail given for this assignment is:
Create an abstract class called Pet. This class should have at least two abstract methods in it. Create two classes named Cat and Dog that implement these abstract methods. Make sure that your Pet class implements the Comparable interface.
Abstract Pet Class:
public abstract class Pet implements Comparable
{
private String name, breed;
Pet(String name, String breed)
{
this.name = name;
this.breed = breed;
}
public String getName()
{
return name;
}
public String getBreed()
{
return breed;
}
//Abstract get methods
public abstract double getAge();
public abstract double getWeight();
}Cat Sub-Class:
public class Cat extends Pet
{
private double age, weight;
Cat(String name, String breed, double age, double weight)
{
super(name, breed);
this.age = age;
this.weight = weight;
}
public double getAge()
{
return age;
}
public double getWeight()
{
return weight;
}
}Error:
Error(3,8): homework2.Cat is not abstract and does not override abstract method compareTo(java.lang.Object) in java.lang.Comparable
What am I doing wrong? The only relevant detail given for this assignment is:
Create an abstract class called Pet. This class should have at least two abstract methods in it. Create two classes named Cat and Dog that implement these abstract methods. Make sure that your Pet class implements the Comparable interface.