Created
March 10, 2021 18:32
-
-
Save yigitgenc/9aa6ac12cac9ad5ae4cd8fe17e5f7c5d to your computer and use it in GitHub Desktop.
Dog.scala
This file contains hidden or 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
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