9/13 error


#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.>

<In what way does your code behave incorrectly? Include ALL error messages.>



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

#2

What’s wrong with it? :slight_smile:


#3

I have no idea what’s wrong here. But the program says I have to call the bark method on the spike object. I think I’ve done it right though.


#4

That might be codecademy’s fault for looking directly at the code file in a very crude way, looking for patterns.
Your whitespace is all over the place, mixed tabs and spaces and inconsistent amounts of indentation, blank lines in methods with no purpose.

And it doesn’t compile, so there’s also that.


#5
public class Dog {
  private int age;
  public Dog(int dogsAge) {
    age = dogsAge;  
  }
  public void bark() {
    System.out.printIn("Woof!");
  }
  public static void main(String[] args) {
    Dog spike = new Dog(14);
    spike.bark();
  }
}

Fixed errors, fixed whitespace.

Now we can figure out if programming or whitespace was the issue.


#6

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