1. Your constructor is wrong, since it only sets
Age = intialAge;
if
intialAge
is less than 0. Check where your closing brace is positioned.
2. Your
yearPasses
function requires four calls to increment the Age value correctly. Read the documentation on prefix and postfix operators. A better way of writing it would be:
public void yearPasses() {
Age += 1;
}
3. You test for
Age < 13
and
Age > 13
but never
Age == 13
. You know that Age will always be greater or equal to zero, so you only need to test for the other values. You should also use
if ... else if ... else
rather than a lot of single
if
clauses.