Skip to content

Instantly share code, notes, and snippets.

@samuelorji
Last active February 25, 2019 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuelorji/049d353d437fd0a08730bbba504c0828 to your computer and use it in GitHub Desktop.
Save samuelorji/049d353d437fd0a08730bbba504c0828 to your computer and use it in GitHub Desktop.
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