Quotes help make search much faster. Example: "Practice Makes Perfect"

Thursday, October 29, 2015

Codecademy > Learn Java > Inheritance Sample Solution


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(100);
    int spikeAge = spike.getAge();
    System.out.println(spikeAge);
    spike.checkStatus();
}

}

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts