This site requires JavaScript, please enable it in your browser!
Greenfoot back
kieran
kieran wrote ...

2016/2/26

Reset the Values of a Wave Help

kieran kieran

2016/2/26

#
public void toggle() { up = !up; if (up) { setImage(downImage); int x = (MIN_X + (int) (RANGE_X/ 2)); this.val = val; value.setText (""+val); if (val < min || val > max) { System.err.println("Value for slider out of range (" + val + ") - ignored"); return; } } else { setImage(downImage); } } public void setValueFromX(int x) { x -= getX(); // convert from absolute to relative offset val = min + (int) ( (x - MIN_X) * ( range / RANGE_X) ); value.setText (""+val); } Here is the code I have so far. I need to reset the amplitude, frequency and damping values for a wave (like a sin or cos wave on a graph) to their initial values (the middle values on their respective "sliders" at the top of my screen). Currently, I have a switch that goes up and down, but when I click the switch, the values do not return to their initial position and my program stops. Any suggestions? Thanks!
danpost danpost

2016/2/26

#
There is some pertinent code missing from your post. Particularly, to start with, the act method (or the method that calls these given methods).
You need to login to post a reply.