Overriding add() Method in java

tllcoolj

Member
Joined
Jun 13, 2019
Posts
11
Likes
3
I have a program that runs fine when tested in NetBeans with a modified add(double, value) method, but when ported to Motivewave and integrated in a strategy it no longer works as it should. Values are not added to the LinkedList except for the first value. The classes in the program are in a separate file from the strategy, but same package and called from the strategy.

<<Here is a snippet of the code:>>
public class DrawDown {
int _n;
int _startIndex, _endIndex, _troughIndex;
public int Count;
private LinkedList<Double> _values;
public double Peak;
public double Trough;

public DrawDown(int n, double peak) {
_n = n - 1;
_startIndex = _n;
_endIndex = _n;
_troughIndex = _n;
Count = 1;
_values = new LinkedList<Double>();
_values.addLast(peak);
Peak = peak;
Trough = peak;
.
.
}
public void add(double newValue) {
_endIndex = _n;
Count++;
_values.addLast(newValue);
if (newValue < Trough) {
Trough = newValue;
_troughIndex = _endIndex;
}
}
.
.
}
class CalculateDrawDown {
private int _n;
public LinkedList<DrawDown> _drawdownObjs;
public DrawDown _currentDrawDown;
public DrawDown _maxDrawDownObj;

public CalculateDrawDown(int, n) { // value passed from strategy
_n = n;
_currentDrawDown = null;
_drawdownObjs = new LinkedList<DrawDown>();
}
public void calculate(double newValue) { //value passed from strategy
.
.
_drawdownObjs.add(_currentDrawDown); // values are not added to the list after first added value!
.
.
}
//other methods follow
.
.
}
It appears that the modified add() method is not executed as it should. I tried to override the java add() method and got
:46: error: method does not override or implement a method from a supertype.

I am learning java and I am at loss on solving this problem. Any help will be greatly appreciated!
 
Top