Hi everyone! I have something like this on the Ap...
# android
a
Hi everyone! I have something like this on the App I'm working on:
Copy code
@Parcelize
data class Order(val fees:List<Fee>, total:Double): Parcelable

@Parcelize
data class Fee(val amount:Double): Parcelable
But now I need another type of Fee, a percentage fee, and I would love some ideas on tackling this problem. My first thought was to use hierarchy to help me with this, something like:
Copy code
@Parcelize
data class Order(val fees:List<IFee>, total:Double): Parcelable

interface IFee {
   fun getTotalFee(): Double
}

@Parcelize
data class AmountFee(val amount: Double) : IFee, Parcelable {
   override fun getTotalFee() = amount
}

@Parcelize
data class PercentageFee(
    val orderTotal:Double,
    val percentage: Double
) : IFee, Parcelable {
   override fun getTotalFee() = (percentage * orderTotal) / 100
}
Until Parcelize started complaining about the interface. I'm not sure if there is a better approach so wanted to check before further working on this solution because Parcelize and data class can be tricky with hierarchy. Any help is appreciated 😁 Thanks in advanced