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();
}
}