This file contains 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