Skip to content

Instantly share code, notes, and snippets.

@13andrew13
Created January 30, 2017 16:37
Show Gist options
  • Save 13andrew13/bf0a68c0ba2842d068f1b5595eb077a4 to your computer and use it in GitHub Desktop.
Save 13andrew13/bf0a68c0ba2842d068f1b5595eb077a4 to your computer and use it in GitHub Desktop.
public class Animal {
protected String name;
protected int age;
protected double weight;
protected double height;
public Animal(String name, int age,double weight,double height) {
this.name = name;
this.age = age;
this.weight = weight;
this.height = height;
}
public void printName(){
System.out.println("It's name is " + name);
}
}
public class Dog extends Animal {
protected String voice = "Bark";
protected String ownerName;
public Dog(String name, int age, double weight, double height, String ownerName) {
super(name, age, weight, height);
this.ownerName = ownerName;
}
public void run(){
System.out.println("It is so fast!");
}
public void jump(){
System.out.println("You can perform in circus");
}
public void bite(){
System.out.println("Let, him/her!!!");
}
public void voice(){
for (int i = 0;i>2;i++)
System.out.println(voice);
}
}
public class Puppy extends Dog {
private String voice = "Gav-gav";
public Puppy(String name, int age, double weight, double height, String ownerName) {
super(name, age, weight, height, ownerName);
}
@Override
public void run(){
System.out.println("Come to me!");
}
@Override
public void jump(){
System.out.println("Good boy!");
}
@Override
public void bite(){
System.out.println("You are so cute!");
}
@Override
public String toString(){
return("Puppy " + name +" is " + age + " years and it's owner is " + ownerName);
}
}
public class PuppyRunner {
public static void main(String[] args) {
Puppy puppy = new Puppy("Jack",2 ,3,45,"John");
System.out.println(puppy.toString());
puppy.voice();
puppy.bite();
puppy.jump();
puppy.run();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment