12&13/13.help,


#1



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


since checkStatus is not defined , console expect to show an error but it shows "Your pet is healthy and happy!" I dont see that on my codes ..why is it??


class Dog extends Animal {
  
  int age;

	public Dog(int dogsAge) {
    
  	age = dogsAge;
    
  }
  
  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();

	}

}


#2

If your class failed to compile perhaps it was running one that you had compiled earlier


#3

I got how it works thank you for your guidance :wink:


#4

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