12/13 part 2


#1


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

The instructions tell me to call the checkStatus method onto the object spike but when I put spike.checkStatus(); it says I've done it incorrectly. What am I doing wrong?


class Dog {
  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

class Dog extends Animal {
    
  }

dont create this. just add extends Animal in first line with class Dog


#3

Thanks I didn't realise I made that mistake.


#4

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