Skip to content

Instantly share code, notes, and snippets.

@yigitgenc
Created March 10, 2021 18:32
Show Gist options
  • Save yigitgenc/9aa6ac12cac9ad5ae4cd8fe17e5f7c5d to your computer and use it in GitHub Desktop.
Save yigitgenc/9aa6ac12cac9ad5ae4cd8fe17e5f7c5d to your computer and use it in GitHub Desktop.
Dog.scala
trait Speaker {
def speak(): String
}
trait TailWagger {
def startTail(): Unit
def stopTail(): Unit
}
trait Runner {
def startRunning(): Unit
def stopRunning(): Unit
}
class Dog extends Speaker with TailWagger with Runner {
// Speaker
override def speak(): String = "Woof!"
// TailWagger
override def startTail(): Unit = println("Tail is wagging")
override def stopTail(): Unit = println("Tail is stopped")
// Runner
override def startRunning(): Unit = println("I'm running")
override def stopRunning(): Unit = println("Stopped running")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment