Exercise 10. Methods: || Confused


#1

As I was trying to complete step 1 by adding a method called run to the Dog Class and I typed it has it showed, I kept getting the red X of failure stating, "Did you create the run method? Place it between the bark and main method.

I looked on the forum, and I placed it where others did, punctuation looked correct and I still kept getting the error message? Anyway, Codecademy gave me the option to get code so I did. Next thing you know it completed steps 1-4 for me?
Can anyone that has done this section explain to me what was wrong with my code when it seemed correctly placed without syntax errors AND why does Codecademy complete all four sections, when I just needed help with step 1?
Thanks!


#2

I'm having the same issue and I came here to find an answer. Not sure why it's not letting me through.


#3

I've also gotten this same problem. What's the deal?


#4

https://www.codecademy.com/courses/learn-java/lessons/object-oriented-programming/exercises/methods-2?action=lesson_resume&link_content_target=interstitial_lesson

Same problem here ... I put the run method where it asked.

In between the bark and main methods, add a method called run to the Dog class by typing:

public void run() {

}

Here's the code:

class Dog {
  int age;

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

  public void bark() {

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

  public void run() {
    
  }

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

  }

}

The same sort of thing happened earlier in this lesson. I clicked the 'get code' button and it gave me EXACTLY what I had written with the exception that the code worked.


#5

I was able to get past this, without having to click the 'get code' button, by going through and completing the rest of the steps before clicking the 'run' button.


#6

It's really stupid, but it works! Thanks a lot.


#7

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