Created
September 15, 2010 17:44
-
-
Save stpettersens/581122 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
/* | |
Groovy class inheritence demonstration | |
*/ | |
class Ancestor { | |
def name | |
Ancestor() { | |
name = "Homo erectus" | |
} | |
def speak() { | |
println "I am " + name | |
} | |
private def hunt() { | |
println "Modern man need not hunt for his food." | |
} | |
} | |
class ModernMan extends Ancestor { | |
ModernMan() { | |
name = "Modern man" | |
} | |
} | |
myAncestor = new Ancestor() | |
myAncestor.speak() | |
myAncestor.hunt() | |
me = new ModernMan() | |
me.speak() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment