How can I create multiple types that are essentially Ints, i.e can get the int value, can use math operators like + BUT where instances of different types can not be mixed.
For example:
val density1 = new Density(100)
val density2 = new Density(200)
density1 + density2 should be(new Density(300))
val variability = new Variability(1)
variability.value should be(1)
density1 + variability // does not compile
There could be hundreds of these types and I do not want to have to implement operators like + in each leaf class.
Ideally, I would like to avoid all implicit conversion mechanisms (personal preference only). Additional types should not require altering existing types.