Hey can you guys help with this? Basically with all that is left? Thank you!

import javax.swing.*;   //for JFrame
import java.awt.*;      //for Graphics and Container
import java.util.Random;
import javax.swing.JOptionPane;
// other import statements here

public class RandomGraphics
    // constants are used to draw the grid, and for you to put shapes in the grid
    public static final int MIDX = 400;
    public static final int MIDY = 300;
    public static final int MAXX = 799;
    public static final int MAXY = 599;

    // make another constant for the color value that will
    // be used to generate a random color
    public static final int COLOR= 256;

    public static void main( String[] args )throws InterruptedException
        //*** This next section sets up the graphics window.
        //*** You are not required to understand it
        Container contentPane;
        Graphics g;
        JFrame win = new JFrame("Random Graphics");
        contentPane = win.getContentPane();
        g = contentPane.getGraphics();
        //*** done setting up graphics window

        // Create Random object
        Random r= new Random();

        // Top left quadrant:
        // Use a JOptionPane to ask the user to enter the number of lines 1 to 100.
        // Use a do..while loop to keep asking until they enter a correct value.
        // Then, in that quadrant, generate the lines with random colors, random
        // starting and ending points.  Use a for loop to draw the lines.

            String ask;
            int lines;
                ask=JOptionPane.showInputDialog("Enter the number of lines [1 to 100]");

        // Draws Grid - DO NOT CHANGE
        // After you use JOptionPane to get the number of lines, you can move this
        // section of code to just after that, so the lines will not disappear
        g.drawLine(0,MIDY,MAXX,MIDY); // horizontal line
        g.drawLine(MIDX,0,MIDX,MAXY); // vertical line

            int i;
            for(i=lines; i>0; i--)
                g.setColor(new Color(r.nextInt(COLOR), r.nextInt(COLOR), r.nextInt(COLOR)));
                g.drawLine(r.nextInt(MIDX), r.nextInt(MIDY), r.nextInt(MIDX), r.nextInt(MIDY));

        // Top right quadrant:
        // Draw 50 squares in top right quadrant with random widths between 2 and 50.
        // The color of each square should be a random red value. Green and blue values
        // should be 0.  Use a while loop to draw the squares.
        int b=0;
            g.setColor(new Color(r.nextInt(COLOR), (0), (0)));
            g.fillRect(MIDX+50, MIDY+50, r.nextInt(48)+2, r.nextInt(48)+2);

        // Bottom left quadrant:
        // Draw 75 frame ovals in lower left quadrant with random widths between 2 and 75
        // and random heights between 5 and 25.  The color should be a random blue value.
        // Red and green values should be 0.  Use a do..while loop to draw the ovals.

        // Bottom right quadrant:
        // Draw a patchwork of 50 x 50 squares of random colors to fill the lower right quadrant
        // Red, green and blue values should all be random.
        // Use nested for loops to draw the squares.


4 Years
Discussion Span
Last Post by NormR1
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.