Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.00 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Graphics;
  3. import java.util.Random;
  4.  
  5.  
  6. public class Cubes {
  7. public Cube[] cubes = new Cube[5000];
  8. int place=0;
  9. public Cubes(){
  10.        
  11. }
  12. public Graphics DrawNormal(Graphics g){
  13.     int x1,x2,x3,x4,x5,y1,y2,y3,y4,y5;
  14.     Random r = new Random();
  15.     x1=r.nextInt(500);
  16.     x2=r.nextInt(Math.abs(400-x1));
  17.     x3=r.nextInt(Math.abs(300+(x1-x2)));
  18.     x4=r.nextInt(Math.abs((400-x1)));
  19.     x5=r.nextInt(Math.abs(200)+x4);
  20.     y1=r.nextInt(Math.abs(400));
  21.     y2=r.nextInt(Math.abs(300-x1));
  22.     y3=r.nextInt(Math.abs(200+(x1-x2)));
  23.     y4=r.nextInt(Math.abs((300-x1)));
  24.     y5=r.nextInt(Math.abs(100)+x4);
  25.  
  26.         cubes[place]= new Cube(x1,y1,Color.red);
  27.         place++;
  28.         cubes[place]= new Cube(x2,y2,Color.red);
  29.         place++;
  30.         cubes[place]= new Cube(x3,y3,Color.red);
  31.         place++;
  32.         cubes[place]= new Cube(x4,y4,Color.red);
  33.         place++;
  34.         cubes[place]= new Cube(x5,y5,Color.red);
  35.         place++;
  36.         for(int i =0;i<5;i++){
  37.             g.draw3DRect(cubes[i].x, cubes[i].y, 30, 40, true);
  38.         }
  39.     return g;
  40.    
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement