Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. public class AdvancedInvestment: GeneralInvestment {
  2. let incremental: Dollars
  3. let period: Years
  4.  
  5. init(initialAmount: Dollars, time: Years, tax: Double, incremental: Dollars, period: Years) {
  6. self.incremental = incremental
  7. self.period = period
  8. super.init(initialAmount: initialAmount, time: time, tax: tax)
  9. }
  10. }
  11.  
  12. public final class InvestmentManager {
  13.  
  14. func calculateReturn(investment: GeneralInvestment) -> Dollars {
  15. if let advanced = investment as? AdvancedInvestment {
  16. return advanced.initialAmount + Double(advanced.time) * (advanced.initialAmount * advanced.tax) + (Double(advanced.period) * (advanced.incremental * advanced.tax))
  17. } else {
  18. return investment.initialAmount + Double(investment.time) * (investment.initialAmount * investment.tax)
  19. }
  20. }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement