Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java Abstract Class Help

Name: Anonymous 2011-02-18 23:29

Can't figure out how to fix this Java error.



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.

Name: Anonymous 2011-02-19 1:57

I just looked through the videos relevant to this assignment, and he basically went over interfaces, inner-classes and exception handling. Implementing the Comparable class wasn't covered at all, aside from being listed as one of the requirements for the assignment.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List