Guest K1u Posted October 4, 2006 Share Posted October 4, 2006 ok sorry for asking a noob question :roll: ... heres my code so far // **************************************************************** // RandomShapes.java // // Author: Kiumarz Hashemi // // The program will draw two filled rectangles and a // filled oval positioned randomly on the screen. // **************************************************************** import java.util.Random; import java.applet.Applet; import java.awt.*; public class RandomShapes extends Applet { public void paint (Graphics page) { Random generator = new Random(); // Declare size constants final int MAX_SIZE = 300; final int PAGE_WIDTH = 600; final int PAGE_HEIGHT = 400; // Declare variables int x, y; // x and y coordinates of upper left-corner of each shape int width, height; // width and height of each shape // Set the background color setBackground (Color.yellow); // Set the color for the next shape to be drawn page.setColor (Color.blue); // Assign the corner point and width and height x = 400; y = 40; width = 50; height = 200; page.fillRect(x, y, width, height); } } Ok what im basically trying to do is making Modify the assignment statements to assign x a random value between 0 and PAGE_WIDTH and y a random value between 0 and PAGE_HEIGHT (use these contant identifiers). Your random values should go up to but not include these maximums. Now i am kinda angry that i cant get this bcuz i pwned the section of random numbers but im having trouble on this assignment... Feel free the modify the code in any way u want ive been reading my java book for about 20 minutes trying endless methods and different things... If any1 wants to run this make this html file (u can do it in notepad) <html> <applet code="RandomShapes.class" width=600 height=400> </applet> </html> All help will be appreciated (just another quick question what would i have to do to make it auto refresh lets say every 3 seconds?) btw: i hate those gay ass comments too teach makes us put em in :x Quote Link to comment Share on other sites More sharing options...
cooper Posted October 4, 2006 Share Posted October 4, 2006 :? What did you try so far? Seems to me all you need to do is: x = generator.nextInt(PAGE_WIDTH); y = generator.nextInt(PAGE_HEIGHT); Quote Link to comment Share on other sites More sharing options...
PoyBoy Posted October 4, 2006 Share Posted October 4, 2006 I know no java whatsoever. Kinda wish i did, but am slightly too lazy to learn... Quote Link to comment Share on other sites More sharing options...
Guest K1u Posted October 5, 2006 Share Posted October 5, 2006 Confused What did you try so far?Seems to me all you need to do is: x = generator.nextInt(PAGE_WIDTH); y = generator.nextInt(PAGE_HEIGHT); Argh thx man im angered that my mind just went blank on something so basic :P :x :P Thanks again :) I know no java whatsoever. Kinda wish i did, but am slightly too lazy to learn... Oh its not a hard language especially if u know C++ go google up a free tutorial and learn it NOW!!! lol :D Quote Link to comment Share on other sites More sharing options...
PoyBoy Posted October 5, 2006 Share Posted October 5, 2006 now. indeed Quote Link to comment Share on other sites More sharing options...
Guest Posted October 5, 2006 Share Posted October 5, 2006 K1u why are you posting all your assignments up here and asking us to do them for you? You had an assignment not that long ago that made you use random numbers, you where told how to manipulate random numbers with code. Im sure the teacher also told you how to. So what was the problem? /me whats for K1u to get his/her next assignment. I wonder what it will be. Quote Link to comment Share on other sites More sharing options...
Guest K1u Posted October 5, 2006 Share Posted October 5, 2006 K1u why are you posting all your assignments up here and asking us to do them for you? You had an assignment not that long ago that made you use random numbers, you where told how to manipulate random numbers with code. Im sure the teacher also told you how to. So what was the problem?/me whats for K1u to get his/her next assignment. I wonder what it will be. :P my next assignment will be... lol jus jking (oh btw im watching a documentary on tv on tom delay and abermoth and some other political douchebags...BASTARDS i hope they burn in hell stuff like this rly wants to make u be into anarchy BASTARDS...) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.