12/13 the checkStatus

everything been going smooth till i got stuck at the “checkStatus” method calling
here is my code

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

public void bark()
{
System.out.println("!Woof");
}

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

public int getAge()
{

return age;
}

public static void main(String args)
{
Dog spike = new dog(2)
spike.bark();
spike.run(10);
int spikeAge =
spike.getAge();
System.out.println(spikeAge);
spike.checkStatus();
}
}

it keeps saying “Did you call the checkStatus method inside of main?”

1 Like

Constructor can’t return anything, even void (the object itself is the implicit return).

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

should be like

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

and
Dog spike = new dog(2) //wrong

creating a Dog object using Dog constructor should be like

Dog spike = new Dog(2); // and need ; after this

1 Like

thnx man , it worked ,appreciate it .

I don’t understand what I am doing wrong. I’ve read the posts that have been put in, tried putting in what you said where it said it should go, and I’m still wrong. Why?

if you have any problem at this lesson then you should create a new topic

1.click on this link
https://discuss.codecademy.com/c/learn-java/object-oriented-programming
2.click on New Topic
3.read the forum carefully. post your code and tell us your problem
4.click on Create Topic

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