#help school project

1 messages · Page 1 of 1 (latest)

bronze totem
#

Can someone please help me quickly with my school project where I need to create 3 different loop patterns?

Here is the template I have

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

// Main class extending JFrame
public class ProgIntroZeichnen extends JFrame{

public ProgIntroZeichnen(){
    super("Learning to Program: First Steps through Explorative Learning. GOOD LUCK! STAY WITH IT!");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    add(new MyPanel(), BorderLayout.CENTER);
    pack();
    setExtendedState(JFrame.MAXIMIZED_BOTH);
    setVisible(true);
}

private class MyPanel extends JPanel{
    public MyPanel() {
        // Background color

// setBackground(Color.black);
setPreferredSize(new Dimension(900, 425));
}

    protected void paintComponent(Graphics g) {
        super.paintComponent(g);

        // This is where the custom method (=subroutine) is called.

        // TODO: Add method calls here. The following example method can be removed.
        zeichne1_QuadratAnzeigen(g);
    }
}

//
// --------------- Display a square, modify parameters, ... ----------------
//

public void zeichne1_QuadratAnzeigen(Graphics g){
    //-----------Insert your own program code here---------------------------------------------

    // The variable g is needed to draw on the screen.
    // For learning programming principles, it is not relevant at the moment!
    Zeichenblatt zeichenblatt = new Zeichenblatt(g);

    // Draw a square (size, color, etc., are predefined)
    Quadrat quad = new Quadrat();
    zeichenblatt.zeichne(quad);
    //---------------------------------------------------------------------------------------
}

//
// ####### START -- the main(String[] args) method is automatically called first by Java
//
public static void main(String[] args) {
    new ProgIntroZeichnen();
}

}

tall harborBOT
#

<@&987246399047479336> please have a look, thanks.

dire swallow
#

We can help answer questions, but we won't write your code for you.

#

What's your specific question?

tall harborBOT
#

Please use this format for posting code:

```java
// Example java program
int value = 5;
System.out.println(value);
```

Which results in:

// Example java program
int value = 5;
System.out.println(value);

For syntax highlighting, you have to add the name of the language after the three backticks, like ```java. Please make sure to use exactly this format, so no space between the backticks and the language name, and a newline before the code starts. If done right, the syntax highlighting will even be applied to your text as you type, before sending.

bronze totem
#

i need this rn but idk how to get to this

my code looks like this bc i tried some things

// Example java program
public void zeichne1_QuadratAnzeigen(Graphics g){

        Zeichenblatt zeichenblatt = new Zeichenblatt(g);
        int f = 0;
        int h= 100;
        for (int T = 0; T < 3; T++) {
            for (int i = 50; i < 200; i++) {
                Quadrat quad = new Quadrat();
                if (i % 2 == 0) {
                    quad.setFarbe(Color.RED);
                }else {
                    quad.setFarbe(Color.ORANGE);
                }
                f++;

                quad.setPositionX(f);
                quad.setPositionY(i);

                zeichenblatt.zeichne(quad);

            }
            f = f + 50;

            for (int z =50; z < 100; z++){
                h--;
                Quadrat quad2 = new Quadrat();
                if (z % 2 == 0) {
                    quad2.setFarbe(Color.RED);
                }else {
                    quad2.setFarbe(Color.ORANGE);
                }

                quad2.setPositionX(h);
                quad2.setPositionY(z);

                zeichenblatt.zeichne(quad2);

            }
            h = h + 150;
        }
tall harborBOT
# bronze totem i need this rn but idk how to get to this my code looks like this bc i tried so...

Detected code, here are some useful tools:

[WARNING] The code couldn't end properly...

Problematic source code:

// Example java program
public void zeichne1_QuadratAnzeigen(Graphics g){

        Zeichenblatt zeichenblatt = new Zeichenblatt(g);
        int f = 0;
        int h= 100;
        for (int T = 0; T < 3; T++) {
            for (int i = 50; i < 200; i++) {
                Quadrat quad = new Quadrat();
                if (i % 2 == 0) {
                    quad.setFarbe(Color.RED);
                }else {
                    quad.setFarbe(Color.ORANGE);
                }
                f++;

                quad.setPositionX(f);
                quad.setPositionY(i);

                zeichenblatt.zeichne(quad);

            }
            f = f + 50;

            for (int z =50; z < 100; z++){
                h--;
                Quadrat quad2 = new Quadrat();
                if (z % 2 == 0) {
                    quad2.setFarbe(Color.RED);
                }else {
                    quad2.setFarbe(Color.ORANGE);
                }

                quad2.setPositionX(h);
                quad2.setPositionY(z);

                zeichenblatt.zeichne(quad2);

            }
            h = h + 150;
        }```
Cause:
The code doesn't compile, there are syntax errors in this code.

## System out
[Nothing]
bronze totem
#

thats what happened 💀

#

i think my first question is why are these blocks so big and why are they not filled but only outlines