Hullaballoonatic
06/16/2019, 5:15 PMAdam Powell
06/16/2019, 5:18 PMlouis993546
06/16/2019, 5:28 PMabstract class Foo constructor(val defaultBar: String = "default") {
abstract fun bar(): String
}
class FooImpl : Foo() {
override fun bar(): String = "$defaultBar bar"
}
is this what you are looking for?Dominaezzz
06/16/2019, 5:30 PMFooImpl("not default")
in addition.Hullaballoonatic
06/16/2019, 5:32 PMsealed class Material(override val stdValue: Money, override val stdWeight: Mass, val stdVolume: Volume) : Item() {
abstract class Liquid(value: Money, weight: Mass, volume: Volume) : Material(value, weight, volume)
abstract class Solid(value: Money, weight: Mass, volume: Volume) : Material(value, weight, volume)
}
so it'd be nice if everything that inherited had a constructor e.g.
class Water private constructor(val value: Money, val weight: Mass, val volume: Volume): Liquid(10.cents, 1.g, 1.mL) {
constructor(value: Money) : this(value, (value / stdValue) * stdMass, (value / stdVolume) * stdVolume)
// etc for other measurements
}
Adam Powell
06/16/2019, 5:34 PMHullaballoonatic
06/16/2019, 5:35 PM