Writing an abstract class for homework - here's what I have so far:
public abstract class Pet {
String petName;
double foodAmount;
double foodSupply;
int days;
public Pet(String petName, double foodSupply) { //constructor to be used by sub-classes
this.petName = petName;
this.foodSupply = foodSupply;
}
public Pet() {//default constructor
}
public void feed() {
while (foodSupply>foodAmount) {
foodSupply = foodSupply-foodAmount;
}
public abstract void eat();
public abstract void talk();
public void print() {
days = (foodSupply)%(foodAmount);
System.out.println(petName+" : "+days+" days left of food supply.");
}
public static void main(String[] args) {
Pet newPet = new Pet;
newPet.talk();
newPet.feed();
newPet.print();
}
}
I'm getting an 'illegal start of type' error for the methods eat(), talk(), and print(). Can anyone help?