Idk why this won’t work I’ve been trying over and over
class Dog {
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) {
spike.checkStatus
Dog spike = new Dog(5);
spike.bark();
spike.run(40);
int spikeAge = spike.getAge();
System.out.println(spikeAge);
}
}
When calling a method you need to call them with an opening and closing parenthesis on the end. Just like your other method calls.
Also, you can only refer to the spike object after it has been created. So you’ll also have to move it (the checkStatus method) further down the scope.
What I would try (copy all the code first) is on the bottom right, click > Get Help. Then in the menu “I want to restart this exercise”. Paste the code back into editor and see what happens.
If not here’s my code for you to have a look at/ try.
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(1);
spike.bark();
spike.run(2);
int spikeAge = spike.getAge();
System.out.println(spikeAge);
spike.checkStatus();
}
}