import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Random; public class Mastermind extends JFrame { private JButton[][] knoppen = new JButton[10][10]; private int[][] kleuren = new int[10][10]; private int[] oplossing = new int[5]; private int test = 1; private int pinkleur = 0; private int spelfase = 0; private Color[] kleur = {Color.ORANGE, Color.GREEN, Color.RED, Color.BLUE, Color.YELLOW, new Color(178, 72, 198)}; private JButton buttontest; private JLabel labelsf; public Mastermind() { setTitle("Mastermind versie 2.2"); setSize(340, 500); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(null); getContentPane().setBackground(new Color(204, 153, 0)); genereerOplossing(); for (int i = 0; i < 5; i++) { for (int j = 0; j < 8; j++) { JButton knop = new JButton(); knop.setBounds((i * 40) + 30, (j * 40) + 80, 30, 30); knop.setBackground(kleur[0]); knop.addActionListener(new KnopListener(i, j)); add(knop); knoppen[i][j] = knop; kleuren[i][j] = 0; } } buttontest = new JButton("Test"); buttontest.setBounds(270, (test * 40) + 40, 60, 30); buttontest.setBackground(Color.RED); buttontest.addActionListener(e -> testen()); add(buttontest); labelsf = new JLabel("Kies een kleur hieronder:"); labelsf.setBounds(10, 400, 200, 30); add(labelsf); setVisible(true); } private void genereerOplossing() { Random rand = new Random(); for (int i = 0; i < 5; i++) { oplossing[i] = rand.nextInt(5) + 1; } } private class KnopListener implements ActionListener { private int x, y; public KnopListener(int x, int y) { this.x = x; this.y = y; } @Override public void actionPerformed(ActionEvent e) { if (y == 9) { pinkleur = x; } else { kleuren[x][y] = pinkleur; knoppen[x][y].setBackground(kleur[pinkleur]); } } } private void testen() { int wit = 0; int zwart = 0; int[] grijs = new int[5]; for (int i = 0; i < 5; i++) { grijs[i] = kleuren[i][test - 1]; if (grijs[i] == oplossing[i]) { wit++; } } // Simpele evaluatie van zwarte pinnen zwart = Math.max(0, Math.min(5, zwart)); if (wit == 5) { labelsf.setText("GEWONNEN"); buttontest.setEnabled(false); } if (test == 9) { labelsf.setText("VERLOREN"); buttontest.setEnabled(false); } test++; } public static void main(String[] args) { new Mastermind(); } }

This is an example page. It’s different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:

Hi there! I’m a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin’ caught in the rain.)

…or something like this:

The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.

As a new WordPress user, you should go to your dashboard to delete this page and create new pages for your content. Have fun!