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


#1

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);

}

}


#2

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);
    }
}

#3

Bit dramatic there for a typo.


#4

it caught the eye,
didn’t it ??


#5

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.


#6

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