Created
January 29, 2014 22:04
-
-
Save GrantSchiller/8698104 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Cat extends Pet { | |
public Cat(){ | |
} | |
public void talk () { | |
System.out.println("purr"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Dog extends Pet { | |
public Dog(){ | |
} | |
public void talk () { | |
System.out.println("bark"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Pet extends Projectile { | |
private String color; | |
private int age; | |
public Pet(){ | |
String color = "Black"; | |
int age = 5; | |
} | |
public Pet(String c, int a){ | |
String color = c; | |
int age = a; | |
} | |
public void jump () { | |
System.out.println("Jump"); | |
} | |
public void eat () { | |
System.out.println("Eat"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Projectile { | |
private int weight; | |
private int hardness; | |
public Projectile() { | |
weight = 8; | |
hardness = 5; | |
} | |
public Projectile(int w, int h) { | |
weight = w; | |
hardness = h; | |
} | |
public void toss() { | |
System.out.println("You cruel bastard"); | |
if (weight > 5) System.out.println(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Runner { | |
public static void main(String[] args){ | |
Cat c = new Cat(); | |
Dog d = new Dog(); | |
d.talk(); | |
c.talk(); | |
d.eat(); | |
c.eat(); | |
d.toss(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment