Код: Выделить всё
public class LinearFunction implements Function {
private final double slope;
private final double yIntercept;
private final double xIntercept;
public LinearFunction(double m, double b) {
this.slope = m;
this.yIntercept = b;
this.xIntercept = -yIntercept / slope;
}
public LinearFunction(LinearFunction f) {
this(f.slope, f.yIntercept);
}
@Override
public Double apply(final Double x) {
return slope * x + yIntercept;
}
}
Copy Constructor не копирует поля xintercept '
, который я не понимаю, потому что xintercept
не понимает
.>
Подробнее здесь: https://stackoverflow.com/questions/691 ... copy-field