Browse Source

removed Main2 and started the initial commit as master

remotes/origin/develop
fdai6499 2 years ago
parent
commit
82bc4b10fd
  1. 98
      sudokuExample/src/Main.java
  2. 55
      sudokuExample/src/Main2.java

98
sudokuExample/src/Main.java

@ -1,59 +1,55 @@
import java.util.Scanner;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
class Main {
//sudoku counts from 1 to 9 - sCount
static final int SCOUNT = 9;
static int field[][] = new int[SCOUNT][SCOUNT];
int ar[] = new int[2];
public class Main {
public static void main(String[] args) { public static void main(String[] args) {
while (true) { //das program läuft unendlich
int[] transaction = readInput(); //starte die methode readinput und die soll werte zurückgeben
//der erste wert von dem array transaction steht für die spalte und der zweite für die reihe und der dritte für den wert den man schreiben will
field[transaction[0]][transaction[1]] = transaction[2];
//gebe das gespeicherte feld auf der console aus
output(field);
}
}
private static void output(int[][] field) {
for (int i = 0; i < SCOUNT; i++) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
for (int j = 0; j < SCOUNT; j++) {
System.out.print(field[i][j] + " ");
} }
System.out.println();
}
}
static int[] readInput() {
Scanner scanner = new Scanner(System.in);
String line = scanner.nextLine();
System.out.println(line);
String substring = line.substring(line.indexOf('(')+1, line.indexOf(')'));
String[] split = substring.split(",");
int[] transaction = new int[split.length];
for (int i = 0; i < split.length; i++) {
transaction[i] = Integer.valueOf(split[i]);
}
return transaction;
});
} }
}
}
// JFrame jFrame = new JFrame();
// jFrame.setVisible(true);
// jFrame.setBounds(300, 300, 500, 500);
//
// JPanel yPanel = new JPanel();
// yPanel.setLayout(new BoxLayout(yPanel, BoxLayout.Y_AXIS));
// yPanel.setBorder(new EmptyBorder(1, 0, 1,0));
//
// JButton jButton1 = new JButton();
// jButton1.setText("Test Button 1");
//
// yPanel.add(jButton1);
//
// JButton jButton2 = new JButton();
// jButton2.setText("Test Button 2");
// yPanel.add(jButton2);
//
// for (int i = 0; i < 9; i++) {
//
// JPanel xPanel = new JPanel();
// xPanel.setLayout(new BoxLayout(xPanel, BoxLayout.X_AXIS));
// xPanel.setBorder(new EmptyBorder(0, 1, 0,1));
//
// for (int j = 0; j < 9; j++) {
//
// JTextField jTextField = new JTextField();
// jTextField.setColumns(1);
// jTextField.setBounds(0, 0, 10, 10);
//
// xPanel.add(jTextField);
//
// }
//
// yPanel.add(xPanel);
// }
//
// jFrame.setContentPane(yPanel);

55
sudokuExample/src/Main2.java

@ -1,55 +0,0 @@
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
public class Main2 {
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
JFrame jFrame = new JFrame();
jFrame.setVisible(true);
jFrame.setBounds(300, 300, 500, 500);
JPanel yPanel = new JPanel();
yPanel.setLayout(new BoxLayout(yPanel, BoxLayout.Y_AXIS));
yPanel.setBorder(new EmptyBorder(1, 0, 1,0));
JButton jButton1 = new JButton();
jButton1.setText("Test Button 1");
yPanel.add(jButton1);
JButton jButton2 = new JButton();
jButton2.setText("Test Button 2");
yPanel.add(jButton2);
for (int i = 0; i < 9; i++) {
JPanel xPanel = new JPanel();
xPanel.setLayout(new BoxLayout(xPanel, BoxLayout.X_AXIS));
xPanel.setBorder(new EmptyBorder(0, 1, 0,1));
for (int j = 0; j < 9; j++) {
JTextField jTextField = new JTextField();
jTextField.setColumns(1);
jTextField.setBounds(0, 0, 10, 10);
xPanel.add(jTextField);
}
yPanel.add(xPanel);
}
jFrame.setContentPane(yPanel);
}
});
}
}
Loading…
Cancel
Save