public void showSpread() {
if (this.waveform == null){ //there is
no data to display
UI.println("No waveform
to display");
return;
}
this.display();
/*# YOUR CODE HERE */
// set min and max to max and min
double min = Double.MAX_VALUE;
double max = Double.MIN_VALUE;
// loop over this.waveform, for each
value in this.waveform:
if
(this.waveform.get(min)<min){
return;
}
// if
this.waveform.get(i); < min then set min = to value
// do the same for max
>
// draw green line for max
UI.setColor(Color.green);
// use max as y1 and y2
UI.drawLine(GRAPH_LEFT, max,
GRAPH_RIGHT, max);
//draw red line for min
UI.setColor(Color.red);
//use min for y1, y2
UI.drawLine(GRAPH_LEFT, min,
GRAPH_RIGHT, min);
}
PLEASE HELP I SUCK AT FOR LOOP STATEMENTS
public void showSpread() { if (this.waveform == null) { //there is no data to display UI.println("No waveform to display"); return; } this.display(); /*# YOUR CODE HERE */ // set min and max to max and min double min = Double.MAX_VALUE; double max = Double.MIN_VALUE; // loop over this.waveform, for each value in this.waveform: if (this.waveform.get(min)<min) { return; } // if this.waveform.get(i); < min then set min = to value // do the same for max > // draw green line for max UI.setColor (Color.green); // use max as y1 and y2 UI.drawLine(GRAPH_LEFT, max, GRAPH_RIGHT, max); //draw red line for min UI.setColor (Color.red); //use min for y1, y2 UI.drawLine(GRAPH_LEFT, min, GRAPH_RIGHT, min); }
public void showSpread() { if (this.waveform == null){ //there is no data to display UI.println("No
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am