11. Using Methods: II } What am I doing wrong?

It keep telling me “Did you add the getAge method? Make sure to place it between the run and main methods.”

I am on step 1

In between the run and main methods, add a method called getAge that returns age by typing:

public int getAge() {

return age;

}

This is my code:

class Dog {

int age;

public Dog(int dogsAge) {

age = dogsAge;

}

public void bark() {

System.out.println("Woof!");

}

public void run(int feet) {

System.out.println("Your dog ran" + feet + "feet!");

}

public in getAge() {

return age;

}

public static void main(String[] args) {

Dog spike = new Dog(5);
spike.bark();
spike.run(20);

}

}

class Dog {
    int age;
    public Dog(int dogsAge) {
        age = dogsAge;
    }
    public void bark() {
        System.out.println("Woof!");
    }
    public void run(int feet) {
        System.out.println("Your dog ran" + feet + "feet!");
    }
    public in getAge() {    <<<<<<<<<<<<What is this !!!!!!!!
        return age;
    }
    public static void main(String[] args) {
        Dog spike = new Dog(5);
        spike.bark();
        spike.run(20);
    }
}
1 Like

Bit dramatic there for a typo.

1 Like

it caught the eye,
didn’t it ??

I think - " You’ve written ‘in’ instead of ‘int’ " would have sufficed - hyperbolic use of exclamation marks
just seems a bit unseemly and in my opinion could be misinterpreted . Some people are sensitive.
I’m not saying our fellow coder is , but it’s a risk. Politeness can be undervalued.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.