...

View Full Version : Loop isn't working on cpu (JCreator)



Jamalrus
01-06-2012, 09:39 PM
I have this code for my programming class and it's not working. I have compared it to other working codes in the class and there is no difference whatsoever. Any help would be appreciated!


import java.awt.*;
import java.awt.event.*;

public class Unit103 extends java.applet.Applet {

Graphics screen;
int x,y,xmove,ymove,running;

public void init() {
x=135;
y=220;
xmove=1;
ymove=1;
running=1;
}

public void paint(Graphics screen) {

while(running<1000);{
screen.setColor(Color.red);
screen.fillRect(x,y,50,50);
for(int counter=1;counter<60000;counter=counter+1){}
screen.setColor(Color.white);
screen.fillRect(x,y,50,50);
if(x>350||x<0);{
xmove=xmove*-1;}
if(y>350||y<0);{
ymove=ymove*-1;}
x=x+xmove;
y=y+ymove;
running=running+1;
}
}
}

Fou-Lu
01-07-2012, 12:23 AM
Watch for these: while(running<1000);{. A semi-colon at the end of a branch signifies that its true once.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum