Page 1 of 1

public void showSpread() { if (this.waveform == null){ //there is no data to display UI.println("No

Posted: Thu May 26, 2022 9:10 am
by answerhappygod
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 1
Public Void Showspread If This Waveform Null There Is No Data To Display Ui Println No 1 (67.38 KiB) Viewed 13 times
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); }