I’ve been trying to figure this out for like 20 minutes, and I still can’t figure it out.
I’m trying to get each individual positive number within listOfNumbers to be negative in order to create a bar graph. I can give more pieces of the code if needed, I’m just completely unsure of what to do.
public void plotLevels(ArrayList<Double> listOfNumbers) {
int base = 350;
int left = 50;
int step = 25;
UI.setColor(Color.black);
for(int i = 0; i <listOfNumbers.size(); i++) {
UI.fillRect(left, base, 20, (listOfNumbers.get(i)));
left += step;
}
>Solution :
If you want the number to be negative within the UI.fillRect, you can replace it with the following:
UI.fillRect(left, base, 20, (listOfNumbers.get(i) * -1));
Because you multiply the number with -1, it will become negavtive.