Hi guys,
In my program i have to draw rectangles, but i need to pause before drawing it depending on the the number it has been assigned. I have created a timing class, which pauses the timer according to the integer. I have used tested the timing class and it works, however, it is not working in my main program, i cant figure out why. I have included the code below, can any of u figure out what the problem is?
Thanks!!
public class timing{ //this is the timing class
public long stop(int a){
if(a==1){
return 150;
}
if(a==2){
return 250;
}
if(a==3){
return 350;
}
if(a==4){
return 450;
}
if(a==5){
return 550;
}
else
return 0;
}
}
import CSLib.*;
import java.awt.*;
public class trying{
public static void main (String [] args){
DrawingBox d = new DrawingBox();
java.util.Random r = new java.util.Random();
int A[] = new int[5];
int x = 30;
colors c = new colors();
timing t = new timing();
for (int i = 0; i <A.length; i++) {
int j = r.nextInt(5)+1;
A=j;
d.setColor(c.decide(A));
d.fillRect(x, 30, 30, 30);
x = (x + 80);
Timer.pause(t.stop(A)); // the timing class works here
}
}
}
public void move() { //this is part of another program
timing u = new timing();
for (int k = 0; k < f; k++) {
for (int i = 0; i < f - 1 - k; i++) {
d.clearRect(A, B, 30, 30);
if (f > 1) {
if (F < C) {
C[0] = F;
F = 0;
d.clearRect(D, E, 30, 30);
Timer.pause(250);
d.setColor(c.decide(C[0]));
d.fillRect(A[0], B[0], 30, 30);
Timer.pause(u.stop(C[0])); // does not work here in this program
}