Results 1 to 6 of 6

Thread: help pleaseee

  1. #1
    csprrung is offline Member
    Join Date
    Apr 2012
    Posts
    8
    Rep Power
    0

    Default help pleaseee

    how do i generate 4 random numbers ?

  2. #2
    csprrung is offline Member
    Join Date
    Apr 2012
    Posts
    8
    Rep Power
    0

    Default Re: help pleaseee

    In this assignment you will write a program to generate random boxes on a 500 x 500 pixel screen. You are to have the program draw 30 boxes. The boxes must have a random position and a random height and width. Make sure that all boxes show up in the window. Here are a couple more stipulations:

    1. If the boxes have a width less than 15 they need to be filled in with magenta.

    2. If the boxes have a height less than 50 and a width greater than 15 they need to be filled in with blue.

    3. All other boxes are just drawn and not filled in.







    import javax.swing.*;
    import java.awt.*;

    public class as19 extends JFrame {

    Container con = getContentPane();
    public as19(){
    con.setBackground(Color.BLUE);

    }
    public void paint(Graphics gr){
    super.paint(gr);
    gr.setColor(Color.RED);
    for(int i = 1;i <= 30;i++){
    for(int j = 1;j <= i;j++){
    System.out.print(i);
    }
    System.out.println();
    }
    }

    //generate 4 random numbers
    //if statements for what to draw

    }
    public static void main(String [] args){

    as19 frame = new as19();
    frame.setSize(200,200);
    frame.setVisible(true);
    }

    }





    heres what i got so far

  3. #3
    Join Date
    May 2012
    Posts
    15
    Rep Power
    0

    Default Re: help pleaseee

    Here's a quick video tutorial that will tell you how to do everything from scratch...

    Java Programming Tutorial - 26 - Random Number Generator - YouTube

  4. #4
    csprrung is offline Member
    Join Date
    Apr 2012
    Posts
    8
    Rep Power
    0

    Default help please

    In this assignment you will write a program to generate random boxes on a 500 x 500 pixel screen. You are to have the program draw 30 boxes. The boxes must have a random position and a random height and width. Make sure that all boxes show up in the window. Here are a couple more stipulations:

    1. If the boxes have a width less than 15 they need to be filled in with magenta.

    2. If the boxes have a height less than 50 and a width greater than 15 they need to be filled in with blue.

    3. All other boxes are just drawn and not filled in

    heres what i got so far

    import javax.swing.*;
    import java.awt.*;
    import java.util.Random;

    public class as19 extends JFrame {

    Container con = getContentPane();
    public as19(){
    con.setBackground(Color.BLUE);

    }
    public void paint(Graphics gr){
    super.paint(gr);
    gr.setColor(Color.RED);
    for(int i = 1;i <= 30;i++){
    for(int j = 1;j <= i;j++){
    System.out.print(i);
    }
    System.out.println();
    }
    }

    Random random = new Random();
    int value = random(10000);
    //if statements for what to draw


    public static void main(String [] args){

    as19 frame = new as19();
    frame.setSize(200,200);
    frame.setVisible(true);
    }
    private int random(int i) {
    // TODO Auto-generated method stub
    return 0;
    }

    }

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Moderator
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    9,918
    Rep Power
    16

    Default Re: help please

    Why do they call it rush hour when nothing moves? - Robin Williams

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Moderator
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    9,918
    Rep Power
    16

    Default Re: help pleaseee

    Don't double post. I've merged the two threads.

    Also, don't post homework questions in Advanced Java.

    db
    Why do they call it rush hour when nothing moves? - Robin Williams

Similar Threads

  1. Replies: 22
    Last Post: 02-24-2011, 05:56 PM
  2. embed chm to java PLEASEEE
    By ashin in forum SWT / JFace
    Replies: 1
    Last Post: 02-19-2011, 07:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •