MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / main

Method main

patterns/strategy/StrategyPattern.java:51–62  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

49
50public 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]

Callers

nothing calls this directly

Calls 2

minimaMethod · 0.95
changeAlgorithmMethod · 0.95

Tested by

no test coverage detected