10. Methods II

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>
The window is showing my code printing correctly, but I am still receiving the error: “Did you create the run method? Place it in between bark and main method.” What am I missing?

```

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 static void main(String args) {

Dog spike = new Dog(7);
spike.bark();
spike.run(5);
}
}

<do not remove the three backticks above>

Did you do the next step before passing the current one? May need to undo that.

I’m having the exact same problem right now
the console even outputs the correct thing, so I don’t know what’s wrong here

class Dog {
int age;
public Dog(int dogsAge){
  age = dogsAge;
}


	public static void main(String[] args) {
    Dog spike = new Dog(5);
    spike.bark();
    spike.run(69);
	}

  public void bark(){
    System.out.println("Woof!");
  }
  
    public void run(int feet) {
    System.out.println("Your dog ran " + feet + " feet!");
  }  

}

Update: I have a solution

Click “Get Help” then click on “I want to restart this excersise”
Then do it step by step, and make sure the run method is between bark and main

for some reason it doesn’t work unless you hit run for every single step

3 Likes

Thanks man that helped!

Thanks guy it’s worked!

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