Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-06-2012, 08:39 PM   PM User | #1
Jamalrus
New to the CF scene

 
Join Date: Dec 2011
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Jamalrus is an unknown quantity at this point
Loop isn't working on cpu (JCreator)

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!

Code:
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;
		}
	}
}
Jamalrus is offline   Reply With Quote
Old 01-06-2012, 11:23 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Watch for these: while(running<1000);{. A semi-colon at the end of a branch signifies that its true once.
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Tags
loop, loops

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:29 PM.


Advertisement
Log in to turn off these ads.