Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sealed trait Type
- object Apple extends Type
- object Orange extends Type
- object Potato extends Type
- object Item {
- def join(i1: Item, i2: Item): Item = Item(i1.t, i1.amount + i2.amount)
- }
- case class Item(t: Type, amount: Int)
- val items = Seq[Item](Item(Apple, 1), Item(Apple, 30), Item(Orange, 1), Item(Apple, 12), Item(Potato, 50))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement