public class Fish
{
// Any fish below this size must be thrown back into the lake
public static int THROW_BACK_SIZE = 18;
protected int size;
protected float weight;
public Fish(int aSize, float aWeight)
{
size = aSize;
weight = aWeight;
}
public boolean canKeep()
{
if (size>THROW_BACK_SIZE){
return true;
}
else{
return false;
}
}
public boolean isDesirableTo(Fisher f)
{
if(size>THROW_BACK_SIZE && Fisher.numFishCaught<Fisher.LIMIT){
return true;
}
else{
return false;
}
}
public int getSize() { return size; }
public float getWeight() { return weight; }
public String toString ()
{
return ("A " + size + "cm " + weight + "kg Fish");
}
}
This is what i currently have under my fish class. I am now suppose to make two subclasses, NonEndangeredFish and EndangeredFish. Under NonEndangeredFish has the subclasses Perch and Bass, while EndangeredFish has AuroraTrout and AtlanticWhiteFish. Note that Fish, NonEndangeredFish and EndangeredFish are all abstract classes, while the other 4 are concrete classes. With the exception of the Fish class, none of the other classes here have any attributes defined within them. This is what I tried to put under my fish class but was unsuccessful.
public abstract class NotEndangeredFish extends Fish{
}
I got this error:
Error: class NotEndangeredFish is public, should be declared in a file name NotEndangeredFish.java
Any help on how to do this properly would be greatly appreciated. Thanks!