The code you quoted is not the solution, it's the original, unrefactored code. The solution uses polymorphism instead of the switch statement.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: Dec 29, 2005
i got a bit confused (because i read some lines not properly). it makes sense now. of course payAmount() gets declared abstract in the superclass, subclasses implement it and switch statement gets kicked out.
subject: Refactoring: Replace Conditional with Polymorphism