12/13 Help


#1

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


Replace this line with your code.


#2

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.


#3

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


#4

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();
	}

}

#5

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?


#6

''' 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


#7

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


#8

Thank you so much admin.... Finally


#9

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