import java.awt.*;
import java.applet.*;
public class FirstApp extends Applet {
public void paint(Graphics g) {
int bottom = 500;
int w = Integer.parseInt(getParameter("barW"));
int h = Integer.parseInt(getParameter("barH"));
String bName1 = getParameter("bName1");
String bName2 = getParameter("bName2");
String bName3 = getParameter("bName3");
String bName4 = getParameter("bName4");
int bLeng1 = Integer.parseInt(getParameter("bLenght1"));
int bLeng2 = Integer.parseInt(getParameter("bLenght2"));
int bLeng3 = Integer.parseInt(getParameter("bLenght3"));
int bLeng4 = Integer.parseInt(getParameter("bLenght4"));
int bLengMAX = 0;
int i = 1;
int height = Integer.parseInt(getParameter("height"));
int [] bLeng = new int[4];
while (i <= 4) {
if (bLeng[i] > bLengMAX)
bLengMAX = bLeng[i]; {
i++; {
g.setColor(Color.blue);
g.fillRect(w, h, 50, ((bottom - (bLeng1 * (bLengMAX/height)))));
g.setColor(Color.red);
g.fillRect((w + 100), h, 50, (bottom - (bLeng2 * (bLengMAX/height))));
g.setColor(Color.green);
g.fillRect((w + 200), h, 50, (bottom - (bLeng3 * (bLengMAX/height))));
g.setColor(Color.cyan);
g.fillRect((w + 300), h, 50, (bottom - (bLeng4 * (bLengMAX/height))));
}
}
}
}
}
It seemed like every time I solved the problem, I ran into another. It currently has me drawing 4 different rectangles, each about 100w from each other with the starting point being stated in the program. The issue I'm having is the height parameter of the rectangles, in which it currently has an algorithm for scaling given by our professor. When I open the .html file that goes with it, I just get 4 rects with the same size. Any suggestion on what I could possibly be doing wrong would be greatly appreciated.

New Topic/Question
Reply



MultiQuote




|