Last active
December 6, 2020 18:20
-
-
Save sonumehrotra/4a5359f1e3bff83f113e63608bb9a1c9 to your computer and use it in GitHub Desktop.
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
import scala.util.Random | |
object TransparentTrait { | |
val Sell = "sell" | |
val Buy = "buy" | |
transparent trait Id { | |
def id: Int | |
} | |
trait Order { | |
def quantity: Int | |
} | |
case class BuyOrder(id: Int, quantity: Int) extends Order, Id | |
case class SellOrder(id: Int, quantity: Int) extends Order, Id | |
def mkOrder(side: String, qty: Int) = | |
if (side.equals(Sell)) SellOrder(mkId, qty) else BuyOrder(mkId, qty) | |
def mkId: Int = Random.nextInt() | |
def test: Unit = println(mkOrder("sell", 100)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment