Using Methods, Excercise 9/13 stuck


#1



https://www.codecademy.com/en/courses/learn-java/lessons/object-oriented-programming/exercises/using-methods-1


I keep getting the following error message: "Did you call the bark method on the spike object? Make sure you call it inside of the main method."
As far as I can tell my code follows the instructions, and I do get the required output at the output window to the right.
Any help on this error will be appreciated.


class Dog{
  
  int age;
  
  public Dog(int dogsAge) {
    
    age = dogsAge;
    
  }
  
  public void bark() {
    
    System.out.println("Woof");
    
  }
  
  public static void main(String[] args) {
    
    Dog spike = new Dog(10);
    spike.bark();
  }
}


#2

@natanmel ,

This might not produce a loud enough bark ...

System.out.println("Woof");

Revisit the instructions here.


#3

In the example class Car, the method startEngine is not in blue text, whereas the method bark is in blue text in the picture yet it is not displayed in blue text in my coding window. Any help woul be much apprecitated as I can't continue till it's fixed.


#4

Hi @jdavis0 and spike :

The color of the text is OK the way it is.

You have this ...

System.out.println("Woof");

As was the case with the original poster, your bark method needs to conform precisely to the instructions of the previous exercise ...

Inside the bark method, type:

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

OK, spike, let's exclaim a nice loud bark! :wink:


#5

Ahh now I understand your earlier reply! Thanks for the late night response!


#6

No problem; just a Woof! from a neighbor's dog that woke me up. :slight_smile:


#8

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