Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AdvancedInvestment: GeneralInvestment {
- let incremental: Dollars
- let period: Years
- init(initialAmount: Dollars, time: Years, tax: Double, incremental: Dollars, period: Years) {
- self.incremental = incremental
- self.period = period
- super.init(initialAmount: initialAmount, time: time, tax: tax)
- }
- }
- public final class InvestmentManager {
- func calculateReturn(investment: GeneralInvestment) -> Dollars {
- if let advanced = investment as? AdvancedInvestment {
- return advanced.initialAmount + Double(advanced.time) * (advanced.initialAmount * advanced.tax) + (Double(advanced.period) * (advanced.incremental * advanced.tax))
- } else {
- return investment.initialAmount + Double(investment.time) * (investment.initialAmount * investment.tax)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement