Skip to main content
public static void flagOfLiberia(Graphics g) {
    Expo.setBackground(g,Expo.black);
    for (int d = 1; d <= numDots; d++) {
        int x = Expo.random(0,1000);
        int y = Expo.random(0,650);

        if (x < 300 && y < 300)
            Expo.setColor(g,Expo.darkBlue);
        else if (y % 100 < 50)
            Expo.setColor(g,Expo.red);
        else
            Expo.setColor(g,Expo.white);
    }    
        drawDot(g,x,y);    // must be run inside the loop
    }
    Expo.setColor(g,Expo.white);
    Expo.fillStar(g,150,150,100,5);
    showName(g,"Liberia");
}

The above should be at least a little improvement. I used a modulus (%) to check every multiple of 100, seeing if the remainder is less than or greater than 50. If you desire a cutoff at 650, then a single if statement can be added before the modulus to check that y is below the threshold. Also, I placed the star after the for loop in order to execute it only once.

public static void flagOfLiberia(Graphics g) {
    Expo.setBackground(g,Expo.black);
    for (int d = 1; d <= numDots; d++) {
        int x = Expo.random(0,1000);
        int y = Expo.random(0,650);

        if (x < 300 && y < 300)
            Expo.setColor(g,Expo.darkBlue);
        else if (y % 100 < 50)
            Expo.setColor(g,Expo.red);
        else
            Expo.setColor(g,Expo.white);
    }
    drawDot(g,x,y);
    Expo.setColor(g,Expo.white);
    Expo.fillStar(g,150,150,100,5);
    showName(g,"Liberia");
}

The above should be at least a little improvement. I used a modulus (%) to check every multiple of 100, seeing if the remainder is less than or greater than 50. If you desire a cutoff at 650, then a single if statement can be added before the modulus to check that y is below the threshold. Also, I placed the star after the for loop in order to execute it only once.

public static void flagOfLiberia(Graphics g) {
    Expo.setBackground(g,Expo.black);
    for (int d = 1; d <= numDots; d++) {
        int x = Expo.random(0,1000);
        int y = Expo.random(0,650);

        if (x < 300 && y < 300)
            Expo.setColor(g,Expo.darkBlue);
        else if (y % 100 < 50)
            Expo.setColor(g,Expo.red);
        else
            Expo.setColor(g,Expo.white);
        
        drawDot(g,x,y);    // must be run inside the loop
    }
    Expo.setColor(g,Expo.white);
    Expo.fillStar(g,150,150,100,5);
    showName(g,"Liberia");
}

The above should be at least a little improvement. I used a modulus (%) to check every multiple of 100, seeing if the remainder is less than or greater than 50. If you desire a cutoff at 650, then a single if statement can be added before the modulus to check that y is below the threshold. Also, I placed the star after the for loop in order to execute it only once.

added 80 characters in body; deleted 29 characters in body
Source Link
public static void flagOfLiberia(Graphics g) {
    Expo.setBackground(g,Expo.black);
    for (int d = 1; d <= numDots; d++) {
        int x = Expo.random(0,1000);
        int y = Expo.random(0,650);

        if (x < 300 && y < 300)
            Expo.setColor(g,Expo.darkBlue);
        else if (y % 100 < 50)
            Expo.setColor(g,Expo.red);
        else
            Expo.setColor(g,Expo.white);
        }
        drawDot(g,x,y);
        Expo.setColor(g,Expo.white);
        Expo.fillStar(g,150,150,100,5);
    }
    showName(g,"Liberia");
}

The above should be at least a little improvement. I used a modulus (%) to check every multiple of 100, seeing if the remainder is less than or greater than 50. If you desire a cutoff at 650, then a single if statement can be added before the modulus to check that y is below the threshold. Also, I placed the star after the for loop in order to execute it only once.

public static void flagOfLiberia(Graphics g) {
    Expo.setBackground(g,Expo.black);
    for (int d = 1; d <= numDots; d++) {
        int x = Expo.random(0,1000);
        int y = Expo.random(0,650);

        if (x < 300 && y < 300)
            Expo.setColor(g,Expo.darkBlue);
        else if (y % 100 < 50)
            Expo.setColor(g,Expo.red);
        else
            Expo.setColor(g,Expo.white);
        
        drawDot(g,x,y);
        Expo.setColor(g,Expo.white);
        Expo.fillStar(g,150,150,100,5);
    }
    showName(g,"Liberia");
}

The above should be at least a little improvement. I used a modulus (%) to check every multiple of 100, seeing if the remainder is less than or greater than 50. If you desire a cutoff at 650, then a single if statement can be added before the modulus to check that y is below the threshold.

public static void flagOfLiberia(Graphics g) {
    Expo.setBackground(g,Expo.black);
    for (int d = 1; d <= numDots; d++) {
        int x = Expo.random(0,1000);
        int y = Expo.random(0,650);

        if (x < 300 && y < 300)
            Expo.setColor(g,Expo.darkBlue);
        else if (y % 100 < 50)
            Expo.setColor(g,Expo.red);
        else
            Expo.setColor(g,Expo.white);
    }
    drawDot(g,x,y);
    Expo.setColor(g,Expo.white);
    Expo.fillStar(g,150,150,100,5);
    showName(g,"Liberia");
}

The above should be at least a little improvement. I used a modulus (%) to check every multiple of 100, seeing if the remainder is less than or greater than 50. If you desire a cutoff at 650, then a single if statement can be added before the modulus to check that y is below the threshold. Also, I placed the star after the for loop in order to execute it only once.

Adding a better explanation.
Source Link
public static void flagOfLiberia(Graphics g) {
    Expo.setBackground(g,Expo.black);
    for (int d = 1; d <= numDots; d++) {
        int x = Expo.random(0,1000);
        int y = Expo.random(0,650);

        if (x < 300 && y < 300)
            Expo.setColor(g,Expo.darkBlue);
        else if (y % 100 < 50)
            Expo.setColor(g,Expo.red);
        else
            Expo.setColor(g,Expo.white);
        
        drawDot(g,x,y);
        Expo.setColor(g,Expo.white);
        Expo.fillStar(g,150,150,100,5);
    }
    showName(g,"Liberia");
}

The above should be at least a little improvement. I used a modulus (%) to check every multiple of 100, seeing if the remainder is less than or greater than 50. If you desire a cutoff at 650, then a single if statement can be added before the modulus to check that y is below the threshold.

public static void flagOfLiberia(Graphics g) {
    Expo.setBackground(g,Expo.black);
    for (int d = 1; d <= numDots; d++) {
        int x = Expo.random(0,1000);
        int y = Expo.random(0,650);

        if (x < 300 && y < 300)
            Expo.setColor(g,Expo.darkBlue);
        else if (y % 100 < 50)
            Expo.setColor(g,Expo.red);
        else
            Expo.setColor(g,Expo.white);
        
        drawDot(g,x,y);
        Expo.setColor(g,Expo.white);
        Expo.fillStar(g,150,150,100,5);
    }
    showName(g,"Liberia");
}

The above should be at least a little improvement.

public static void flagOfLiberia(Graphics g) {
    Expo.setBackground(g,Expo.black);
    for (int d = 1; d <= numDots; d++) {
        int x = Expo.random(0,1000);
        int y = Expo.random(0,650);

        if (x < 300 && y < 300)
            Expo.setColor(g,Expo.darkBlue);
        else if (y % 100 < 50)
            Expo.setColor(g,Expo.red);
        else
            Expo.setColor(g,Expo.white);
        
        drawDot(g,x,y);
        Expo.setColor(g,Expo.white);
        Expo.fillStar(g,150,150,100,5);
    }
    showName(g,"Liberia");
}

The above should be at least a little improvement. I used a modulus (%) to check every multiple of 100, seeing if the remainder is less than or greater than 50. If you desire a cutoff at 650, then a single if statement can be added before the modulus to check that y is below the threshold.

Source Link
Loading