Hi....
I have 2 files: Interface 'Car' and Class 'MyCar'
I have never worked with interfaces before but I am getting the error:
MyCar.java:6: MyCar is not abstract and does not override abstract method compareTo(Car) in java.lang.Comparable
Please help!!
/** * Class to represent cars * @author * @version ONE 05/04/2010 */ public class MyCar implements Car { public String getModel() { return model; } public String getRegNo() { return regNo; } public int getYear() { return year; } public int getPrice() { return price; } public void setPrice(int priceNew) { price=priceNew; } public int getCompCount() { return 1; } public boolean match(String model, int year, int price) { if(thisModel == model && thisYear == year && thisPrice == price) { return true; } } public String toString() { String carString = ("Price: " + price + " Year : " + year + " Reg Number : " + regNo + " Registration : " + model); return carString; } }
/** * Interface for a class to represent cars. * @ * @version 1.4 - 15/1/10 */ public interface Car extends Comparable<Car> { /** * Get the car's model description * @return the model */ public String getModel(); /** * Get the car's registration number * @return the regNo */ public String getRegNo(); /** * Get the car's year of registration * @return the year */ public int getYear(); /** * Get the car's price * @return the price */ public int getPrice(); /** * Set the car's price * @param price the price */ public void setPrice(int price); /** * Get & reset the comparison counter value * @return the count (before resetting to zero) */ public int getCompCount(); /** * Check for "near match" (see assignment brief for details) * @param model ignore if null/empty, else match as substring * @param year ignore if <= 0, else match to within 1 yr * @param price ignore if <= 0, else match to within 10% * @return true if "near match" as above, else false */ public boolean match(String model, int year, int price); /** * Create a string with price, year, regNo & model description * concatenated in that order, separated by single tabs * @return a printable string as above */ public String toString(); }