Compare commits
2 Commits
12c0c1fa30
...
567f7f13a3
Author | SHA1 | Date |
---|---|---|
|
567f7f13a3 | |
|
f63e15985f |
|
@ -1,48 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<!-- JRE System Library -->
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21">
|
<attributes>
|
||||||
<attributes>
|
<attribute name="module" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
</attributes>
|
||||||
</attributes>
|
</classpathentry>
|
||||||
</classpathentry>
|
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
|
||||||
|
<classpathentry kind="lib" path="src/main/java/de/hs_mannheim/informatik/mvn/domain/HitoriMain.java"/>
|
||||||
<!-- JUnit Library -->
|
<classpathentry kind="output" path="bin"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
|
|
||||||
|
|
||||||
<!-- Main Source Folder -->
|
|
||||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="optional" value="true"/>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
|
|
||||||
<!-- Test Source Folder -->
|
|
||||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="optional" value="true"/>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
<attribute name="test" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
|
|
||||||
<!-- Test Resources -->
|
|
||||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="test" value="true"/>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
<attribute name="optional" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
|
|
||||||
<!-- Maven Dependencies -->
|
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
|
|
||||||
<!-- Output Folder -->
|
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -10,14 +10,8 @@
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<transformers>
|
<transformers>
|
||||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||||
<mainClass>src.main.java</mainClass>
|
<mainClass>src.main.java.de.hs_mannheim.informatik.mvn.domain.HitoriMain</mainClass>
|
||||||
</transformer>
|
</transformer>
|
||||||
</transformers>
|
</transformers>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,2 +0,0 @@
|
||||||
emre
|
|
||||||
berat
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,41 +0,0 @@
|
||||||
5,8,2,6,3,7,7,5,1,8
|
|
||||||
8,4,2,2,1,9,9,3,7,5
|
|
||||||
3,2,7,8,2,5,5,4,3,10
|
|
||||||
10,2,3,1,7,8,6,9,9,9
|
|
||||||
3,3,3,7,6,2,4,10,4,1
|
|
||||||
4,5,9,10,6,10,1,7,8,8
|
|
||||||
2,7,5,9,1,10,3,1,3,6
|
|
||||||
9,5,4,3,8,10,2,9,10,4
|
|
||||||
9,6,10,8,5,3,10,2,5,8
|
|
||||||
9,10,2,2,4,7,9,8,5,7
|
|
||||||
|
|
||||||
// Lösung (schwarze Felder)
|
|
||||||
1,1
|
|
||||||
1,3
|
|
||||||
1,6
|
|
||||||
1,10
|
|
||||||
2,4
|
|
||||||
2,7
|
|
||||||
3,2
|
|
||||||
3,6
|
|
||||||
3,9
|
|
||||||
4,8
|
|
||||||
4,10
|
|
||||||
5,1
|
|
||||||
5,3
|
|
||||||
5,5
|
|
||||||
5,7
|
|
||||||
6,2
|
|
||||||
6,6
|
|
||||||
6,10
|
|
||||||
7,5
|
|
||||||
7,9
|
|
||||||
8,1
|
|
||||||
8,3
|
|
||||||
8,6
|
|
||||||
9,4
|
|
||||||
9,7
|
|
||||||
9,9
|
|
||||||
10,1
|
|
||||||
10,3
|
|
||||||
10,10
|
|
Can't render this file because it has a wrong number of fields in line 12.
|
|
@ -1,83 +0,0 @@
|
||||||
7,1,2,9,12,15,8,11,11,9,11,14,13,6,3
|
|
||||||
2,3,8,1,2,11,10,9,5,8,14,3,12,13,15
|
|
||||||
4,14,13,9,4,15,9,10,12,6,5,3,11,5,12
|
|
||||||
15,9,5,6,10,15,1,15,8,3,5,4,6,2,8
|
|
||||||
5,11,7,9,15,1,4,3,8,1,9,2,10,13,2
|
|
||||||
15,15,10,3,1,14,8,12,11,1,9,8,2,7,2
|
|
||||||
10,7,7,12,9,3,15,2,5,2,10,5,1,7,4
|
|
||||||
3,8,9,14,1,6,12,4,15,2,13,11,5,10,11
|
|
||||||
8,6,7,15,11,4,5,11,2,10,3,13,8,12,9
|
|
||||||
2,2,3,3,4,13,5,6,5,11,5,15,8,9,12
|
|
||||||
2,15,15,11,13,7,6,5,3,13,8,10,5,1,11
|
|
||||||
12,5,11,13,13,2,2,8,8,4,10,9,3,2,5
|
|
||||||
1,13,8,2,1,7,11,4,9,15,4,12,9,3,10
|
|
||||||
13,10,12,5,15,3,2,7,13,14,12,12,9,11,6
|
|
||||||
7,12,4,8,14,10,13,13,7,4,2,6,15,15,11
|
|
||||||
|
|
||||||
//Lösung
|
|
||||||
1,4
|
|
||||||
1,6
|
|
||||||
1,8
|
|
||||||
1,11
|
|
||||||
2,1
|
|
||||||
2,3
|
|
||||||
2,9
|
|
||||||
2,12
|
|
||||||
2,14
|
|
||||||
3,5
|
|
||||||
3,7
|
|
||||||
3,11
|
|
||||||
3,15
|
|
||||||
4,1
|
|
||||||
4,3
|
|
||||||
4,6
|
|
||||||
4,9
|
|
||||||
4,13
|
|
||||||
5,4
|
|
||||||
5,10
|
|
||||||
5,15
|
|
||||||
6,2
|
|
||||||
6,5
|
|
||||||
6,7
|
|
||||||
6,9
|
|
||||||
6,11
|
|
||||||
6,13
|
|
||||||
7,1
|
|
||||||
7,3
|
|
||||||
7,6
|
|
||||||
7,8
|
|
||||||
7,12
|
|
||||||
7,14
|
|
||||||
8,5
|
|
||||||
8,9
|
|
||||||
8,15
|
|
||||||
9,3
|
|
||||||
9,8
|
|
||||||
9,13
|
|
||||||
10,1
|
|
||||||
10,4
|
|
||||||
10,7
|
|
||||||
10,9
|
|
||||||
10,11
|
|
||||||
11,3
|
|
||||||
11,10
|
|
||||||
11,13
|
|
||||||
11,15
|
|
||||||
12,2
|
|
||||||
12,5
|
|
||||||
12,7
|
|
||||||
12,9
|
|
||||||
12,11
|
|
||||||
12,14
|
|
||||||
13,1
|
|
||||||
13,6
|
|
||||||
13,8
|
|
||||||
13,13
|
|
||||||
14,3
|
|
||||||
14,5
|
|
||||||
14,9
|
|
||||||
14,12
|
|
||||||
15,1
|
|
||||||
15,7
|
|
||||||
15,10
|
|
||||||
15,14
|
|
Can't render this file because it has a wrong number of fields in line 17.
|
|
@ -1,11 +0,0 @@
|
||||||
3,3,1,4
|
|
||||||
4,3,2,2
|
|
||||||
1,3,4,2
|
|
||||||
3,4,3,2
|
|
||||||
|
|
||||||
//Lösung (schwarze Felder)
|
|
||||||
1,2
|
|
||||||
2,4
|
|
||||||
3,2
|
|
||||||
4,1
|
|
||||||
4,4
|
|
|
|
@ -1,15 +0,0 @@
|
||||||
3,4,5,5,2
|
|
||||||
3,2,3,5,4
|
|
||||||
2,1,4,5,5
|
|
||||||
2,3,1,4,1
|
|
||||||
2,5,2,3,2
|
|
||||||
|
|
||||||
//Lösung (schwarze Felder)
|
|
||||||
1,1
|
|
||||||
1,4
|
|
||||||
2,3
|
|
||||||
3,1
|
|
||||||
3,4
|
|
||||||
4,3
|
|
||||||
5,1
|
|
||||||
5,5
|
|
|
|
@ -1,29 +0,0 @@
|
||||||
2,7,2,1,5,8,3,5
|
|
||||||
6,6,1,6,2,4,4,7
|
|
||||||
7,5,8,2,6,6,6,1
|
|
||||||
3,6,8,8,4,2,1,8
|
|
||||||
6,4,7,7,8,2,6,3
|
|
||||||
1,6,4,5,1,3,5,8
|
|
||||||
8,1,3,3,6,4,2,6
|
|
||||||
5,3,6,4,3,4,8,2
|
|
||||||
|
|
||||||
// Lösung (schwarze Felder)
|
|
||||||
1,1
|
|
||||||
1,8
|
|
||||||
2,2
|
|
||||||
2,4
|
|
||||||
2,6
|
|
||||||
3,5
|
|
||||||
3,7
|
|
||||||
4,3
|
|
||||||
4,8
|
|
||||||
5,1
|
|
||||||
5,4
|
|
||||||
5,6
|
|
||||||
6,2
|
|
||||||
6,5
|
|
||||||
6,7
|
|
||||||
7,4
|
|
||||||
7,8
|
|
||||||
8,2
|
|
||||||
8,6
|
|
|
|
@ -1,30 +0,0 @@
|
||||||
4,4,3,5,6,5,7,7
|
|
||||||
8,5,7,6,8,4,7,1
|
|
||||||
7,2,1,2,4,6,2,3
|
|
||||||
8,6,5,2,7,7,3,6
|
|
||||||
3,1,2,7,3,8,6,4
|
|
||||||
1,2,4,1,5,7,3,2
|
|
||||||
5,8,2,4,3,4,1,5
|
|
||||||
2,4,5,1,8,3,8,1
|
|
||||||
|
|
||||||
//Lösung (schwarze Zahlen)
|
|
||||||
1,2
|
|
||||||
1,4
|
|
||||||
1,8
|
|
||||||
2,5
|
|
||||||
2,7
|
|
||||||
3,2
|
|
||||||
3,4
|
|
||||||
4,1
|
|
||||||
4,6
|
|
||||||
4,8
|
|
||||||
5,3
|
|
||||||
5,5
|
|
||||||
6,2
|
|
||||||
6,4
|
|
||||||
6,7
|
|
||||||
7,1
|
|
||||||
7,6
|
|
||||||
8,3
|
|
||||||
8,5
|
|
||||||
8,8
|
|
|
Binary file not shown.
|
@ -1,4 +1,4 @@
|
||||||
package de.hs_mannheim.informatik.pr2projekt.domain;
|
package domain;
|
||||||
|
|
||||||
import java.awt.CardLayout;
|
import java.awt.CardLayout;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
@ -20,8 +20,8 @@ import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import de.hs_mannheim.informatik.pr2projekt.gui.GameGUI;
|
import gui.GameGUI;
|
||||||
import de.hs_mannheim.informatik.pr2projekt.gui.MenuGUI;
|
import gui.MenuGUI;
|
||||||
|
|
||||||
public class HitoriMain extends JFrame implements ActionListener{
|
public class HitoriMain extends JFrame implements ActionListener{
|
||||||
|
|
||||||
|
|
|
@ -1,234 +0,0 @@
|
||||||
package de.hs_mannheim.informatik.mvn.domain;
|
|
||||||
|
|
||||||
import java.awt.CardLayout;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.Scanner;
|
|
||||||
import java.util.Stack;
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
import de.hs_mannheim.informatik.mvn.gui.*;
|
|
||||||
|
|
||||||
public class HitoriMain2 extends JFrame implements ActionListener{
|
|
||||||
|
|
||||||
private static String[] filepath = {"", ""};
|
|
||||||
|
|
||||||
public static void main(String[] args) throws FileNotFoundException{
|
|
||||||
new MenuGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ablauf(CardLayout cl, JPanel main, String[] filepath) throws FileNotFoundException {
|
|
||||||
Stack<String> madeMoves = new Stack<>();
|
|
||||||
String[][] data = getData(filepath[0], Integer.parseInt(filepath[1]));
|
|
||||||
String[][] colors = makeColorArray(data.length);
|
|
||||||
JButton[][] buttons = makeButtonArray(data);
|
|
||||||
GameGUI.paintGame(cl, main, filepath, buttons, colors, madeMoves, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ArrayList<String> readFromFile(String path){
|
|
||||||
ArrayList<String> lines = new ArrayList<>();
|
|
||||||
try (BufferedReader reader = new BufferedReader(new FileReader(path))) {
|
|
||||||
String line;
|
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
lines.add(line);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return lines;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[][] getData(String filepath, int rows) throws FileNotFoundException{
|
|
||||||
Scanner sc = new Scanner(new File(filepath));
|
|
||||||
String[][] data = new String[rows][rows];
|
|
||||||
int rowInt = 0;
|
|
||||||
while (sc.hasNextLine() && rowInt < rows) {
|
|
||||||
String line = sc.nextLine();
|
|
||||||
data[rowInt] = line.split(",");
|
|
||||||
rowInt++;
|
|
||||||
}
|
|
||||||
sc.close();
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static String[][] makeColorArray(int size){
|
|
||||||
String[][] colors = new String[size][size];
|
|
||||||
for(int i=0;i<size;i++){
|
|
||||||
for(int j=0;j<size;j++){
|
|
||||||
colors[i][j] = "W";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return colors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JButton[][] makeButtonArray(String[][] data){
|
|
||||||
JButton[][] buttons = new JButton[data.length][data.length];
|
|
||||||
for(int i=0;i<data.length;i++){
|
|
||||||
for(int j=0;j<data.length;j++){
|
|
||||||
String number = data[i][j];
|
|
||||||
JButton b = new JButton(number);
|
|
||||||
buttons[i][j] = b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return buttons;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean abgabeMöglich(String path, String[][] data, String[][] colors) throws FileNotFoundException{
|
|
||||||
boolean abgabeMöglich = false;
|
|
||||||
String[][] result = getResult(data, colors);
|
|
||||||
ArrayList<String> filteredData = getSolution(path, result);
|
|
||||||
String[][] ergebnis1 = getErgebnisArray(result, filteredData);
|
|
||||||
int count = 0;
|
|
||||||
for(int i=0;i<result.length;i++){
|
|
||||||
for(int j=0;j<result.length;j++){
|
|
||||||
if(result[i][j].equals(ergebnis1[i][j])){
|
|
||||||
} else {
|
|
||||||
count--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(count <0){
|
|
||||||
abgabeMöglich = false;
|
|
||||||
} else {
|
|
||||||
abgabeMöglich = true;
|
|
||||||
}
|
|
||||||
return abgabeMöglich;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[] getCords(int i, int j){
|
|
||||||
String yKoordinate = String.valueOf(i);
|
|
||||||
String xKoordinate = String.valueOf(j);
|
|
||||||
String[] pos = {yKoordinate, xKoordinate};
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void totalResetButton(CardLayout cl, JPanel main, JButton[][] buttons, String[][] colors,Stack<String> madeMoves,String[][] data) throws FileNotFoundException{
|
|
||||||
madeMoves.clear();
|
|
||||||
for(int i = 0; i<data.length;i++){
|
|
||||||
for(int j = 0; j<data.length;j++){
|
|
||||||
colors[i][j] = "W";
|
|
||||||
buttons[i][j] = null;
|
|
||||||
}
|
|
||||||
JButton[][] buttons0 = makeButtonArray(data);
|
|
||||||
GameGUI.paintGame(cl, main, filepath, buttons0, colors, madeMoves, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[][] getResult(String[][] data, String[][] colors){
|
|
||||||
String[][] result = new String[data.length][data.length];
|
|
||||||
for(int i=0;i<data.length;i++){
|
|
||||||
for(int j=0;j<data.length;j++){
|
|
||||||
String farben = colors[i][j];
|
|
||||||
String lastColor = String.valueOf(farben.charAt(farben.length() - 1));
|
|
||||||
if(lastColor.equals("G")){
|
|
||||||
lastColor = "W";
|
|
||||||
}
|
|
||||||
result[i][j] = lastColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ArrayList<String> getSolution(String path, String[][] result) throws FileNotFoundException{
|
|
||||||
Scanner sc = new Scanner(new File(path));
|
|
||||||
ArrayList<String> filteredData = new ArrayList<>();
|
|
||||||
boolean isUnderComment = false;
|
|
||||||
while (sc.hasNextLine()) {
|
|
||||||
String line = sc.nextLine().trim();
|
|
||||||
if (line.equals("//Lösung (schwarze Felder)")) {
|
|
||||||
isUnderComment = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (isUnderComment && !line.isEmpty()) {
|
|
||||||
String[] lineArray = line.split(",");
|
|
||||||
int num1 = Integer.parseInt(lineArray[0]);
|
|
||||||
int num2 = Integer.parseInt(lineArray[1]);
|
|
||||||
String newNum1 = String.valueOf(num1-1);
|
|
||||||
String newNum2 = String.valueOf(num2-1);
|
|
||||||
String newLine = newNum1+","+newNum2;
|
|
||||||
filteredData.add(newLine);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sc.close();
|
|
||||||
return filteredData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[][] getErgebnisArray(String[][] result, ArrayList<String> filteredData){
|
|
||||||
String[][] ergebnis = new String[result.length][result.length];
|
|
||||||
for(int i=0;i<result.length;i++){
|
|
||||||
for(int j=0;j<result.length;j++){
|
|
||||||
ergebnis[i][j] = "W";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (String index : filteredData) {
|
|
||||||
String[] parts = index.split(",");
|
|
||||||
int row = Integer.parseInt(parts[0].trim());
|
|
||||||
int col = Integer.parseInt(parts[1].trim());
|
|
||||||
if (row >= 0 && row < ergebnis.length && col >= 0 && col < ergebnis[row].length) {
|
|
||||||
ergebnis[row][col] = "B";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ergebnis;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sortByTime(String path) throws FileNotFoundException, IOException{
|
|
||||||
File file = new File(path);
|
|
||||||
ArrayList<HighscoreEintrag> highscores = new ArrayList<>();
|
|
||||||
|
|
||||||
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
|
|
||||||
String line;
|
|
||||||
while ((line = br.readLine()) != null) {
|
|
||||||
String[] parts = line.split(" ", 2);
|
|
||||||
String timeStr = parts[0];
|
|
||||||
String name = parts.length > 1 ? parts[1] : "";
|
|
||||||
|
|
||||||
String[] timeParts = timeStr.split(":");
|
|
||||||
int hour = Integer.parseInt(timeParts[0]);
|
|
||||||
int minute = Integer.parseInt(timeParts[1]);
|
|
||||||
LocalTime time = LocalTime.of(hour, minute);
|
|
||||||
|
|
||||||
highscores.add(new HighscoreEintrag(time, name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
highscores.sort(Comparator.comparing(e -> e.time));
|
|
||||||
|
|
||||||
try (BufferedWriter bw = new BufferedWriter(new FileWriter(file))) {
|
|
||||||
for (HighscoreEintrag e : highscores) {
|
|
||||||
String formattedTime = String.format("%02d:%02d", e.time.getHour(), e.time.getMinute());
|
|
||||||
bw.write(formattedTime + " " + e.name);
|
|
||||||
bw.newLine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class HighscoreEintrag {
|
|
||||||
LocalTime time;
|
|
||||||
String name;
|
|
||||||
|
|
||||||
HighscoreEintrag(LocalTime time, String name) {
|
|
||||||
this.time = time;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
package de.hs_mannheim.informatik.mvn.domain;
|
package src.main.java.de.hs_mannheim.informatik.mvn.domain;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
@ -9,7 +9,7 @@ import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class LogHighscores {
|
public class LogHighscores {
|
||||||
private static final Logger logger = LogManager.getLogger(LogHighscores.class);
|
private static final Logger logger = LogManager.getLogger(LogHighscore.class);
|
||||||
|
|
||||||
public static void newRecord(String path, String username, String time) throws FileNotFoundException {
|
public static void newRecord(String path, String username, String time) throws FileNotFoundException {
|
||||||
String timePart = time.substring("Zeit: ".length()).trim();
|
String timePart = time.substring("Zeit: ".length()).trim();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package de.hs_mannheim.informatik.mvn.gui;
|
package src.test.java.de.hs_mannheim.informatik.mvn.gui;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.CardLayout;
|
import java.awt.CardLayout;
|
||||||
|
@ -19,7 +19,8 @@ import javax.swing.JPanel;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import de.hs_mannheim.informatik.mvn.domain.*;
|
import src.main.java.de.hs_mannheim.informatik.mvn.domain.HitoriMain;
|
||||||
|
import src.main.java.de.hs_mannheim.informatik.mvn.domain.LogHighscores;
|
||||||
|
|
||||||
public class GameGUI extends JFrame implements ActionListener {
|
public class GameGUI extends JFrame implements ActionListener {
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ public class GameGUI extends JFrame implements ActionListener {
|
||||||
b.setFocusPainted(false);
|
b.setFocusPainted(false);
|
||||||
b.setBackground(Color.WHITE);
|
b.setBackground(Color.WHITE);
|
||||||
gameGrid.add(b);
|
gameGrid.add(b);
|
||||||
String[] pos = HitoriMain2.getCords(i,j);
|
String[] pos = HitoriMain.getCords(i,j);
|
||||||
b.addActionListener(e -> {paintButton(cl, main, b, pos, colors , madeMoves);});
|
b.addActionListener(e -> {paintButton(cl, main, b, pos, colors , madeMoves);});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +58,7 @@ public class GameGUI extends JFrame implements ActionListener {
|
||||||
b1.addActionListener(e -> {backOneStep(cl, main, madeMoves, buttons, colors, gameGrid);});
|
b1.addActionListener(e -> {backOneStep(cl, main, madeMoves, buttons, colors, gameGrid);});
|
||||||
JButton b2 = new JButton("Zurücksetzen");
|
JButton b2 = new JButton("Zurücksetzen");
|
||||||
b2.addActionListener(e -> {try {
|
b2.addActionListener(e -> {try {
|
||||||
HitoriMain2.totalResetButton(cl, main, buttons, colors, madeMoves, data);
|
HitoriMain.totalResetButton(cl, main, buttons, colors, madeMoves, data);
|
||||||
} catch (FileNotFoundException e1) {
|
} catch (FileNotFoundException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}});
|
}});
|
||||||
|
@ -70,7 +71,7 @@ public class GameGUI extends JFrame implements ActionListener {
|
||||||
topGrid.add(timeLabel);
|
topGrid.add(timeLabel);
|
||||||
topGrid.revalidate();
|
topGrid.revalidate();
|
||||||
topGrid.repaint();
|
topGrid.repaint();
|
||||||
boolean isOkay = HitoriMain2.abgabeMöglich(path, data, colors);
|
boolean isOkay = HitoriMain.abgabeMöglich(path, data, colors);
|
||||||
levelFinished[0] = isOkay;
|
levelFinished[0] = isOkay;
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
startTimer();
|
startTimer();
|
||||||
|
@ -95,7 +96,7 @@ public class GameGUI extends JFrame implements ActionListener {
|
||||||
|
|
||||||
b3.addActionListener(e -> {
|
b3.addActionListener(e -> {
|
||||||
try {
|
try {
|
||||||
levelFinished[0] = HitoriMain2.abgabeMöglich(path, data, colors);
|
levelFinished[0] = HitoriMain.abgabeMöglich(path, data, colors);
|
||||||
System.out.println("0000: " + levelFinished[0]);
|
System.out.println("0000: " + levelFinished[0]);
|
||||||
} catch (FileNotFoundException e1) {
|
} catch (FileNotFoundException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package de.hs_mannheim.informatik.mvn.gui;
|
package src.test.java.de.hs_mannheim.informatik.mvn.gui;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.CardLayout;
|
import java.awt.CardLayout;
|
||||||
|
@ -16,7 +16,7 @@ import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import de.hs_mannheim.informatik.mvn.domain.*;
|
import src.main.java.de.hs_mannheim.informatik.mvn.domain.HitoriMain;
|
||||||
|
|
||||||
public class HighscoreGUI extends JFrame implements ActionListener {
|
public class HighscoreGUI extends JFrame implements ActionListener {
|
||||||
|
|
||||||
|
@ -38,12 +38,12 @@ public class HighscoreGUI extends JFrame implements ActionListener {
|
||||||
b0.addActionListener(e -> {
|
b0.addActionListener(e -> {
|
||||||
int j = count[0];
|
int j = count[0];
|
||||||
String[] paths = {
|
String[] paths = {
|
||||||
"src/main/java/de/hs_mannheim/informatik/mvn/resources/Hitori_Highscores/Hitori4x4_leicht.txt",
|
"resources/Hitori_Highscores/Hitori4x4_leicht.txt",
|
||||||
"src/main/java/de/hs_mannheim/informatik/mvn/resources/Hitori_Highscores/Hitori5x5leicht.txt",
|
"resources/Hitori_Highscores/Hitori5x5leicht.txt",
|
||||||
"src/main/java/de/hs_mannheim/informatik/mvn/resources/Hitori_Highscores/Hitori8x8leicht.txt",
|
"resources/Hitori_Highscores/Hitori8x8leicht.txt",
|
||||||
"src/main/java/de/hs_mannheim/informatik/mvn/resources/Hitori_Highscores/Hitori8x8medium.txt",
|
"resources/Hitori_Highscores/Hitori8x8medium.txt",
|
||||||
"src/main/java/de/hs_mannheim/informatik/mvn/resources/Hitori_Highscores/Hitori10x10medium.txt",
|
"resources/Hitori_Highscores/Hitori10x10medium.txt",
|
||||||
"src/main/java/de/hs_mannheim/informatik/mvn/resources/Hitori_Highscores/Hitori15x15_medium.txt"
|
"resources/Hitori_Highscores/Hitori15x15_medium.txt"
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
showHighscores(cl, main, paths[j]);
|
showHighscores(cl, main, paths[j]);
|
||||||
|
@ -69,22 +69,21 @@ public class HighscoreGUI extends JFrame implements ActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showHighscores(CardLayout cl, JPanel main, String path) throws FileNotFoundException, IOException{
|
public static void showHighscores(CardLayout cl, JPanel main, String path) throws FileNotFoundException, IOException{
|
||||||
HitoriMain2.sortByTime(path);
|
HitoriMain.sortByTime(path);
|
||||||
JPanel mainPanel = new JPanel(new BorderLayout());
|
JPanel mainPanel = new JPanel(new BorderLayout());
|
||||||
File file = new File(path);
|
File file = new File(path);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
try (Scanner scanner = new Scanner(file)) {
|
try (Scanner scanner = new Scanner(file)) {
|
||||||
while (scanner.hasNextLine()) {
|
while (scanner.hasNextLine()) {
|
||||||
if(scanner.nextLine() != "") {
|
scanner.nextLine();
|
||||||
i++;
|
i++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
JPanel highscorePanel = new JPanel(new GridLayout(i,1,10,10));
|
JPanel highscorePanel = new JPanel(new GridLayout(i,1,10,10));
|
||||||
if(i>0){
|
if(i>0){
|
||||||
ArrayList<String> lines = HitoriMain2.readFromFile(path);
|
ArrayList<String> lines = HitoriMain.readFromFile(path);
|
||||||
for(String s: lines){
|
for(String s: lines){
|
||||||
JLabel text = new JLabel(s);
|
JLabel text = new JLabel(s);
|
||||||
highscorePanel.add(text);
|
highscorePanel.add(text);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package de.hs_mannheim.informatik.mvn.gui;
|
package src.test.java.de.hs_mannheim.informatik.mvn.gui;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.CardLayout;
|
import java.awt.CardLayout;
|
||||||
|
@ -13,7 +13,7 @@ import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import de.hs_mannheim.informatik.mvn.domain.*;
|
import src.main.java.de.hs_mannheim.informatik.mvn.domain.HitoriMain;
|
||||||
|
|
||||||
public class MenuGUI extends JFrame implements ActionListener {
|
public class MenuGUI extends JFrame implements ActionListener {
|
||||||
|
|
||||||
|
@ -42,16 +42,13 @@ public class MenuGUI extends JFrame implements ActionListener {
|
||||||
String currentDirectory = Paths.get("").toAbsolutePath().toString();
|
String currentDirectory = Paths.get("").toAbsolutePath().toString();
|
||||||
System.out.println("Current Working Directory: " + currentDirectory);
|
System.out.println("Current Working Directory: " + currentDirectory);
|
||||||
String[] paths = {
|
String[] paths = {
|
||||||
"src/main/java/de/hs_mannheim/informatik/mvn/resources/Hitori_Spielfelder/Hitori4x4_leicht.csv",
|
"resources/Hitori_Spielfelder/Hitori4x4_leicht.csv",
|
||||||
"src/main/java/de/hs_mannheim/informatik/mvn/resources/Hitori_Spielfelder/Hitori5x5leicht.csv",
|
"resources/Hitori_Spielfelder/Hitori5x5leicht.csv",
|
||||||
"src/main/java/de/hs_mannheim/informatik/mvn/resources/Hitori_Spielfelder/Hitori8x8leicht.csv",
|
"resources/Hitori_Spielfelder/Hitori8x8leicht.csv",
|
||||||
"src/main/java/de/hs_mannheim/informatik/mvn/resources/Hitori_Spielfelder/Hitori8x8medium.csv",
|
"resources/Hitori_Spielfelder/Hitori8x8medium.csv",
|
||||||
"src/main/java/de/hs_mannheim/informatik/mvn/resources/Hitori_Spielfelder/Hitori10x10medium.csv",
|
"resources/Hitori_Spielfelder/Hitori10x10medium.csv",
|
||||||
"src/main/java/de/hs_mannheim/informatik/mvn/resources/Hitori_Spielfelder/Hitori15x15_medium.csv"
|
"resources/Hitori_Spielfelder/Hitori15x15_medium.csv"
|
||||||
};
|
};
|
||||||
// /Users/beratkocak/git/PR2Projekt/PR2Projekt/src/main/java/de/hs_mannheim/informatik/mvn
|
|
||||||
|
|
||||||
|
|
||||||
for (String path : paths) {
|
for (String path : paths) {
|
||||||
File file = new File(path);
|
File file = new File(path);
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
|
@ -65,7 +62,7 @@ public class MenuGUI extends JFrame implements ActionListener {
|
||||||
filepath[0] = paths[j];
|
filepath[0] = paths[j];
|
||||||
filepath[1] = num[0];
|
filepath[1] = num[0];
|
||||||
try{
|
try{
|
||||||
HitoriMain2.ablauf(cl, main, filepath);
|
HitoriMain.ablauf(cl, main, filepath);
|
||||||
} catch (FileNotFoundException s){
|
} catch (FileNotFoundException s){
|
||||||
System.out.println("Fehler: " + s.getMessage());
|
System.out.println("Fehler: " + s.getMessage());
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,2 @@
|
||||||
|
emre
|
||||||
|
berat
|
Binary file not shown.
Binary file not shown.
|
@ -1,9 +1,9 @@
|
||||||
package java.de.hs_mannheim.informatik.mvn.test;
|
package src.test.java.de.hs_mannheim.informatik.mvn.test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import de.hs_mannheim.informatik.mvn.domain.HitoriMain2;
|
import src.java.main.de.hs_mannheim.informatik.domain.HitoriMain;
|
||||||
import de.hs_mannheim.informatik.mvn.gui.GameGUI;
|
import src.java.main.de.hs_mannheim.informatik.gui.GameGUI;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ class HitoriTest{
|
||||||
{"W", "W", "W"},
|
{"W", "W", "W"},
|
||||||
{"W", "W", "W"}
|
{"W", "W", "W"}
|
||||||
};
|
};
|
||||||
assertTrue(Arrays.deepEquals(array3x3, HitoriMain2.makeColorArray(3)));
|
assertTrue(Arrays.deepEquals(array3x3, HitoriMain.makeColorArray(3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -25,7 +25,7 @@ class HitoriTest{
|
||||||
{"W", "W", "W"},
|
{"W", "W", "W"},
|
||||||
{"W", "W", "W"},
|
{"W", "W", "W"},
|
||||||
};
|
};
|
||||||
assertFalse(Arrays.deepEquals(array3x2, HitoriMain2.makeColorArray(3)));
|
assertFalse(Arrays.deepEquals(array3x2, HitoriMain.makeColorArray(3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -47,7 +47,7 @@ class HitoriTest{
|
||||||
{"B", "W", "W", "B"}};
|
{"B", "W", "W", "B"}};
|
||||||
String path = "C:/Users/Berat/Desktop/hitoriNew/src/main/java/de/hs_mannheim/informatik/mvn/Hitori_Highscores/Hitori4x4_leicht.txt";
|
String path = "C:/Users/Berat/Desktop/hitoriNew/src/main/java/de/hs_mannheim/informatik/mvn/Hitori_Highscores/Hitori4x4_leicht.txt";
|
||||||
try {
|
try {
|
||||||
assertFalse(HitoriMain2.abgabeMöglich(path, data, colors));
|
assertFalse(HitoriMain.abgabeMöglich(path, data, colors));
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ class HitoriTest{
|
||||||
{"B", "W", "W", "B"}};
|
{"B", "W", "W", "B"}};
|
||||||
String path = "C:/Users/Berat/Desktop/hitoriNew/src/main/java/de/hs_mannheim/informatik/mvn/Hitori_Spielfelder/Hitori4x4_leicht.csv";
|
String path = "C:/Users/Berat/Desktop/hitoriNew/src/main/java/de/hs_mannheim/informatik/mvn/Hitori_Spielfelder/Hitori4x4_leicht.csv";
|
||||||
try {
|
try {
|
||||||
assertTrue(HitoriMain2.abgabeMöglich(path, data, colors));
|
assertTrue(HitoriMain.abgabeMöglich(path, data, colors));
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ class HitoriTest{
|
||||||
{"W", "B", "W", "W", "W"}};
|
{"W", "B", "W", "W", "W"}};
|
||||||
String path = "C:/Users/Berat/Desktop/hitoriNew/src/main/java/de/hs_mannheim/informatik/mvn/Hitori_Spielfelder/Hitori5x5_leicht.csv";
|
String path = "C:/Users/Berat/Desktop/hitoriNew/src/main/java/de/hs_mannheim/informatik/mvn/Hitori_Spielfelder/Hitori5x5_leicht.csv";
|
||||||
try {
|
try {
|
||||||
assertFalse(HitoriMain2.abgabeMöglich(path, data, colors));
|
assertFalse(HitoriMain.abgabeMöglich(path, data, colors));
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ class HitoriTest{
|
||||||
{"B", "W", "W", "W", "B"}};
|
{"B", "W", "W", "W", "B"}};
|
||||||
String path = "C:/Users/Berat/Desktop/hitoriNew/src/main/java/de/hs_mannheim/informatik/mvn/Hitori_Spielfelder/Hitori5x5_leicht.csv";
|
String path = "C:/Users/Berat/Desktop/hitoriNew/src/main/java/de/hs_mannheim/informatik/mvn/Hitori_Spielfelder/Hitori5x5_leicht.csv";
|
||||||
try {
|
try {
|
||||||
assertTrue(HitoriMain2.abgabeMöglich(path, data, colors));
|
assertTrue(HitoriMain.abgabeMöglich(path, data, colors));
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -120,12 +120,12 @@ class HitoriTest{
|
||||||
@Test
|
@Test
|
||||||
void test8() {
|
void test8() {
|
||||||
String[] array = {"3", "4"};
|
String[] array = {"3", "4"};
|
||||||
assertFalse(Arrays.deepEquals(array, HitoriMain2.getCords(3, 3)));
|
assertFalse(Arrays.deepEquals(array, HitoriMain.getCords(3, 3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void test9() {
|
void test9() {
|
||||||
String[] array = {"3", "4"};
|
String[] array = {"3", "4"};
|
||||||
assertTrue(Arrays.deepEquals(array, HitoriMain2.getCords(3, 4)));
|
assertTrue(Arrays.deepEquals(array, HitoriMain.getCords(3, 4)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue