12/13 what should i do?


#1

this one is over my head. need help, pls. thanks

the task:
1.Note that there are now two files in the code editor. Within the Dog class, use the extends keyword to inherit from the Animal class.

below is my script. what should i do?

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 void extends(Animal){}
}
public static void main(String[] args) {
Dog spike=new Dog(1);
spike.bark();
spike.run(1);
int spikeAge=spike.getAge();
System.out.println(spikeAge);

}


#2

What information are you missing that isn't already in the instructions? (Be specific)


#3

i read the instruction, but i don't get it. can you explain it in a simple language? or show me the correct code structure.


#4

If I don't know what's missing in the instructions that are there, then I have no way of knowing how I avoid the same thing happening again and my explanation is likely wasted. So, that's why I want to know what you're looking for, other than the already finished code which I have no interest in giving out. Right now it sounds like you didn't read what's in the "Learn" tab at all, since that contains what to me looks like a well explained example that can easily be applied to the code in the editor.

Ideally you wouldn't ask for anything to be explained as that is too open-ended (time-sink, the person who answers may feel like they waste their time, or simply not do it at all) - and instead ask (specific) questions about the pieces that you are missing. If you missed all of it, then my reply is really to read over that part of the instructions a few more times.

Generally, the person who's asking should be spending more time on the question than the person who answers. Writing "I don't understand, please explain it to me" is the opposite of that.


#5

The correct code is

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(15);
spike.bark();
spike.run(50);
int spikeAge = spike.getAge();
System.out.println(spikeAge);
spike.checkStatus();

}
}