-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSodaFountain.scala
74 lines (59 loc) · 1.38 KB
/
SodaFountain.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// SodaFountain.scala
package sodafountain
object Quantity extends Enumeration {
type Quantity = Value
val None, Small, Regular,
Extra, Super = Value
}
import Quantity._
object Holder extends Enumeration {
type Holder = Value
val Bowl, Cup, Cone, WaffleCone = Value
}
import Holder._
trait Flavor
object Syrup extends Enumeration {
case class _Val() extends Val
with Flavor
type Syrup = _Val
val Chocolate, HotFudge,
Butterscotch, Caramel = _Val()
}
import Syrup._
object IceCream extends Enumeration {
case class _Val() extends Val
with Flavor
type IceCream = _Val
val Chocolate, Vanilla, Strawberry,
Coffee, MochaFudge, RumRaisin,
ButterPecan = _Val()
}
import IceCream._
object Sprinkle extends Enumeration {
case class _Val() extends Val
with Flavor
type Sprinkle = _Val
val None, Chocolate, Rainbow = _Val()
}
import Sprinkle._
trait Amount {
val quant:Quantity
}
trait Taste[F <: Flavor] extends Amount {
val flavor:F
}
case class
Scoop(quant:Quantity, flavor:IceCream)
extends Taste[IceCream]
trait Topping
case class
Sprinkles(quant:Quantity, flavor:Sprinkle)
extends Taste[Sprinkle] with Topping
case class
Sauce(quant:Quantity, flavor:Syrup)
extends Taste[Syrup] with Topping
case class WhippedCream(quant:Quantity)
extends Amount with Topping
case class Nuts(quant:Quantity)
extends Amount with Topping
class Cherry extends Topping