(String[] args)
| 49 | |
| 50 | public class StrategyPattern { |
| 51 | public static void main(String[] args) { |
| 52 | MinimaSolver solver = |
| 53 | new MinimaSolver(new LeastSquares()); |
| 54 | List<Double> line = Arrays.asList( |
| 55 | 1.0, 2.0, 1.0, 2.0, -1.0, |
| 56 | 3.0, 4.0, 5.0, 4.0 ); |
| 57 | System.out.println(solver.minima(line)); |
| 58 | solver.changeAlgorithm(new Perturbation()); |
| 59 | System.out.println(solver.minima(line)); |
| 60 | solver.changeAlgorithm(new Bisection()); |
| 61 | System.out.println(solver.minima(line)); |
| 62 | } |
| 63 | } |
| 64 | /* Output: |
| 65 | [1.1, 2.2] |
nothing calls this directly
no test coverage detected