Skip to content

Instantly share code, notes, and snippets.

@samuelorji
Last active February 25, 2019 15:27
Embed
What would you like to do?
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