Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- abstract class AlgorithmState[ResultType](sum: Int) {
- def produce(option: Int)
- }
- class IntAlg(sum: Int) extends AlgorithmState[Int] (sum) {
- def produce(option: Int) = new IntAlg(sum - option)
- }
- class StringAlg(sum: Int) extends AlgorithmState[Int] (sum) {
- def produce(option: Int) = new StringAlg(sum - option)
- }
- // the produce method is identical for Str and Int algorithms. Can I move it into the abstract parent class?
- // How do I instantiate appropriate child objects?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement