concept Scissors in category scala

This is an excerpt from Manning's book Get Programming with Scala.
In the previous unit, you have mastered how to create a simple HTTP server. In this lesson, you’ll discover an essential tool in your Scala’s toolbox, called “case class”. When coding, dealing with data is a fundamental and recurring task. A case class provides a convenient and efficient way to represent your data in an immutable way: this allows you to share data between multiple threads safely. Being able to express data efficiently and conveniently is essential to make sure our program works correctly. You will also learn about case objects and how they can be useful when serialization is involved. Finally, you will see how pattern matching provides dedicated support for case classes thanks to the unapply function. In the capstone, you’ll use case classes and case objects to represent the core elements of the game “Paper, Rock, Scissors, Lizard, Spock!”.
In this capstone, you’ll implement an HTTP server to play a popular variation of the classic game “Paper, Rock, Scissors!”, called “Rock, Paper, Scissors, Lizard, Spock!”. Two players play the game by each picking a symbol randomly: the selected symbols determine who the winner is. The allowed moves are Paper, Rock, Scissors, Lizard, Spock and they interact as follows:
Listing 26.2: Creating instances for Symbol
// file src/main/scala/org/example/game/entities/Symbol.scala package org.example.game.entities sealed trait Symbol { //#A protected def beats: List[Symbol] def wins(other: Symbol): Boolean = beats.contains(other) } /** * Rock crushes Lizard * Rock crushes Scissors. */ case object Rock extends Symbol { //#B protected val beats = List(Lizard, Scissors) } /** * Paper covers Rock * Paper disproves Spock */ case object Paper extends Symbol { //#B protected val beats = List(Rock, Spock) } /** * Scissors cuts Paper * Scissors decapitates Lizard */ case object Scissors extends Symbol { //#B protected val beats = List(Paper, Lizard) } /** * Lizard poisons Spock * Lizard eats Paper */ case object Lizard extends Symbol { //#B protected val beats = List(Spock, Paper) } /** * Spock smashes Scissors * Spock vaporizes Rock */ case object Spock extends Symbol { //#B protected val beats = List(Scissors, Rock) }