Skip to content

Instantly share code, notes, and snippets.

Created April 23, 2014 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/11204828 to your computer and use it in GitHub Desktop.
Save anonymous/11204828 to your computer and use it in GitHub Desktop.
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