Skip to content

Instantly share code, notes, and snippets.

/TestTraitEx4.groovy
Created Apr 23, 2014

Embed
What would you like to do?
trait Dealer {
def getProfit() {
println 'Dealer.getProfit()'
}
def deal() {
println 'Dealer.deal()'
}
}
trait CarDealer extends Dealer {
def deal() {
println 'CarDealer.deal()'
}
}
class OnlineCarDealer implements CarDealer {
def deal() {
println 'OnlineCarDealer.deal()'
}
}
class OnlineCarDealer2 implements CarDealer {
}
obj = new OnlineCarDealer()
obj.getProfit() // Dealer.getProfit()
obj.deal() // OnlineCarDealer.deal()
obj2 = new OnlineCarDealer2()
obj2.getProfit() // Dealer.getProfit()
obj2.deal(); // CarDealer.deal()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.