I have the following code
class dog{
String name;
int barksLeft;
int bark(int howManyTimes){
while(howManyTimes >3){
System.out.println("woff!");
howManyTimes-=1;
return howManyTimes;
}
}
}
public class implementDog{
public static void main (String[] args) {
dog pupy = new dog();
pupy.barksLeft = pupy.bark(6);
System.out.println("You have "+pupy.barksLeft+" barks left");
}
}
When I compile it, I get this error
implementDog.java:10: error: missing return statement
}
^
1 error
Here's what I checked:
- The "bark" method is not void and expects an int to be returned
- The variable being return is of type int as well
- What I want to do, is to populate the reference variable pupy.barksleft with the return value of the method, so that then I can print it.
What am I missing?