12/13 Help

I tried all the solutions possible but it still gave me an error
Can anyone give me the answer so i can compare with mine as i believe mine is right .
Thank you

https://www.codecademy.com/en/courses/learn-java/lessons/object-oriented-programming/exercises/inheritance?action=resume

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

```

Replace this line with your code.

<do not remove the three backticks above>

Pretty much says it all. We cannot see your code since the link takes us to our own workspace. Please post the code you have. Thanks.

i’m sorry i’m still new to this
Would you care to explain which code i should post ?
Do you mean the error message ?
Sorry for the inconvenience

class Dog {
  
  int age;

	public Dog(int dogsAge) {
    
  	age = dogsAge;
    
  }
  
  class Dog extends Animal{
    
  }
  
  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(5);
    spike.bark();
    spike.run(40);
    int spikeAge = spike.getAge();
    System.out.println(spikeAge);
		spike.checkStatus();
	}

} 

Code and error messages are both valualbe pieces of information if we wish to get a quick response that zeroes in our problem. What error message(s) are you getting with this exercise?

β€˜β€™β€™ Dog.java:11: error: class Dog is already defined in package unnamed package
class Dog extends Animal{
^
Dog.java:35: error: non-static variable this cannot be referenced from a static context
Dog spike = new Dog(5);
^
Dog.java:36: error: cannot find symbol
spike.bark();
^
symbol: method bark()
location: variable spike of type Dog.Dog
Dog.java:37: error: cannot find symbol
spike.run(40);
^
symbol: method run(int)
location: variable spike of type Dog.Dog
Dog.java:38: error: cannot find symbol
int spikeAge = spike.getAge();
^
symbol: method getAge()
location: variable spike of type Dog.Dog
5 errors β€˜β€™β€™

when i remove spike.checkStatus(); i get some answers but there is still part that i can get trough
The spike.checkStatus(); i put it inside the main and it keep asking if i put inside the main

Everything should be inside this object. Remove the top line of your code, and put everything in here.

Thank you so much admin… Finally

1 Like

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