Last active
February 25, 2019 15:27
-
-
Save samuelorji/049d353d437fd0a08730bbba504c0828 to your computer and use it in GitHub Desktop.
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
sealed trait Animal { | |
def speakLikeAnimal : Unit | |
//some other method for animals | |
} | |
case class Cat (name : String , sound : String) extends Animal{ | |
override def speakLikeAnimal: Unit = println(s"I am $name and the sound i make is $sound") | |
} | |
case class Parrot(name : String,sound : String) extends Animal { | |
override def speakLikeAnimal: Unit = println(s"I am $name and the sound i make is $sound") | |
} | |
//other animals of type Animal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment