Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This is my code.
- data class PriceInfo (
- val ratePerTimeUnit: String,
- // ratePerMonth is ratePerTimeUnit*24*30
- val ratePerMonth: String,
- // ratePerYear is ratePerTimeUnit*24*365
- val ratePerYear: String,
- }
- //Ivo's comments
- Does this really need to be optional? Yes for ECS we need to calculate it, but if we always calculate it, then we know that it will always be there, right?
- We could even move the calculation into this data class, possibly in the constructor even -- as you need to supply the rateTimePerUnit anyway?
- //Does he mean to write like this?
- data class PriceInfo (
- val ratePerTimeUnit: String,
- // ratePerMonth is ratePerTimeUnit*24*30
- val ratePerMonth: String = String.format("%.2f",(Double.parseDouble(ratePerTimeUnit) * 24.0 * 30.0)),
- // ratePerYear is ratePerTimeUnit*24*365
- val ratePerYear: String = String.format("%.2f",(Double.parseDouble(ratePerTimeUnit) * 24.0 * 365.0))
- }
- //But how to write the code about create new PriceInfo
- val PriceInfo = PriceInfo( 10.0, ?, ?)
- //Or like this
- data class PriceInfo (
- val ratePerTimeUnit: String
- ){
- val ratePerMonth: String = String.format("%.2f",(Double.parseDouble(ratePerTimeUnit) * 24.0 * 30.0))
- val ratePerYear: String = String.format("%.2f",(Double.parseDouble(ratePerTimeUnit) * 24.0 * 365.0))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement