Skip to content

Instantly share code, notes, and snippets.

@stpettersens
Created September 15, 2010 17:44
Show Gist options
  • Save stpettersens/581122 to your computer and use it in GitHub Desktop.
Save stpettersens/581122 to your computer and use it in GitHub Desktop.
/*
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