0

// Also attached to this question is the assignment sheet. Need help pls.

import java.util.;
import java.awt.
;
import java.applet.*;

public class Lab15st extends Applet

{

private int numBars;        // number of bars to be sorted
private int barHeight[];    // array of bar heights
private int sortDelay;      // delay between comparison iteration

public void init()
{
    numBars = 47;
    sortDelay = 20;  // Change to 50 is using the "Selection Sort".
    barHeight = new int[numBars];
    getBarValues();
}

public void getBarValues()
{
    Random rand = new Random(3333);
    for (int k = 0; k < numBars; k++)
        barHeight[k] = rand.nextInt(591) + 10;  // range of 10..600
}

public void paint(Graphics g)
{
    showFrame(g);
    displayBars(g);
    sortBars(g);

    // Delete the following three lines
    // for the 100 & 110 point versions.
    Expo.delay(3000);
    showFrame(g);
    displayBars(g);
}

public void showFrame(Graphics g)
{
    Expo.setBackground(g,Expo.black);
    Expo.setColor(g,Expo.white);
    Expo.fillRectangle(g,20,20,980,630);
}

public void drawBar(Graphics g, int k)
{
    int y2 = 630;
    int x1 = 35 + k * 20;
    int y1 = y2 - barHeight[k];
    int x2 = x1 + 10;
    Expo.setColor(g,Expo.red);
    Expo.fillRectangle(g,x1,y1,x2,y2);
}

public void eraseBar(Graphics g, int k) // not used in 80 point version
{

}

public void displayBars(Graphics g)
{
    for (int k = 0; k < numBars; k++)
        drawBar(g,k);
}

public void swap(Graphics g, int m, int n)  // Graphics parameter not
{                                           // used in 80 point version

}

public void sortBars(Graphics g)            // Graphics parameter not
{                                           // used in 80 point version

} 

}
2
Contributors
2
Replies
12
Views
6 Months
Discussion Span
Last Post by CS_GUY1234
1
  1. AWT and Applet are decades out of date. You should be using Swing and JApplet.

  2. I can't be bothered to load and read your word docx. What exactly is your question here?
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.