Methods: II


#1

<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.>
https://www.codecademy.com/courses/learn-java/lessons/object-oriented-programming/exercises/methods-2?action=lesson_resume&link_content_target=interstitial_undefined

<In what way does your code behave incorrectly? Include ALL error messages.>
Not sure what is wrong with my code but it wouldn’t let me continue. The console output is:

woof!
Your dog ran 9 feet!

====Did you create the run method? Place it between the bark and main method.====



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

	}

}



#2

Does the exercise ask for “woof!” or “Woof!”?

Capitalization is key.


#3

They did ask for “Woof!” but that was from the exercise before and it went through fine then.


#4

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