From 9a5cffb92c29d7ca93207583ee89b8e14d899ab0 Mon Sep 17 00:00:00 2001 From: Arkadiusz Hypki Date: Tue, 9 May 2023 16:05:40 +0200 Subject: [PATCH] 'Added first version of chess interface;' --- .gitignore | 10 +++++ chess-java-interface-dummy/pom.xml | 18 +++++++++ .../wmi/oop/chess/dummy/BasicStudent.java | 16 ++++++++ .../src/test/java/net/hypki/temp/AppTest.java | 38 +++++++++++++++++++ chess-java-interface/pom.xml | 18 +++++++++ .../hypki/wmi/oop/chess/ChessInterface.java | 11 ++++++ chess-match/pom.xml | 18 +++++++++ .../hypki/wmi/oop/chess/ChessMatchMain.java | 33 ++++++++++++++++ .../src/test/java/net/hypki/temp/AppTest.java | 38 +++++++++++++++++++ prosty-projekt-obiektowy-uwagi.txt | 2 + python/net/hypki/Figure.py | 2 +- python/net/hypki/Main.py | 5 ++- 12 files changed, 206 insertions(+), 3 deletions(-) create mode 100644 chess-java-interface-dummy/pom.xml create mode 100644 chess-java-interface-dummy/src/main/java/net/hypki/wmi/oop/chess/dummy/BasicStudent.java create mode 100644 chess-java-interface-dummy/src/test/java/net/hypki/temp/AppTest.java create mode 100644 chess-java-interface/pom.xml create mode 100644 chess-java-interface/src/main/java/net/hypki/wmi/oop/chess/ChessInterface.java create mode 100644 chess-match/pom.xml create mode 100644 chess-match/src/main/java/net/hypki/wmi/oop/chess/ChessMatchMain.java create mode 100644 chess-match/src/test/java/net/hypki/temp/AppTest.java create mode 100644 prosty-projekt-obiektowy-uwagi.txt diff --git a/.gitignore b/.gitignore index 3e305ce..e5c9913 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,13 @@ bin python/net/__pycache__ python/net/hypki/__pycache__ +chess-match/.classpath +python/.project +chess-match/target +chess-match/.project +chess-java-interface-dummy/.classpath +chess-java-interface-dummy/.project +chess-java-interface-dummy/target +chess-java-interface/.classpath +chess-java-interface/.project +chess-java-interface/target diff --git a/chess-java-interface-dummy/pom.xml b/chess-java-interface-dummy/pom.xml new file mode 100644 index 0000000..7742a7e --- /dev/null +++ b/chess-java-interface-dummy/pom.xml @@ -0,0 +1,18 @@ + + 4.0.0 + net.hypki.temp + temp + jar + 0.1.0 + temp + http://maven.apache.org + + + junit + junit + 3.8.1 + test + + + diff --git a/chess-java-interface-dummy/src/main/java/net/hypki/wmi/oop/chess/dummy/BasicStudent.java b/chess-java-interface-dummy/src/main/java/net/hypki/wmi/oop/chess/dummy/BasicStudent.java new file mode 100644 index 0000000..2012d27 --- /dev/null +++ b/chess-java-interface-dummy/src/main/java/net/hypki/wmi/oop/chess/dummy/BasicStudent.java @@ -0,0 +1,16 @@ +package net.hypki.wmi.oop.chess.dummy; + +import net.hypki.wmi.oop.chess.ChessInterface; + +public class BasicStudent implements ChessInterface { + + @Override + public String nextMove(String opponentMove) { + return opponentMove; + } + + @Override + public void printBoard() { + System.out.println("Not implemented yet"); + } +} diff --git a/chess-java-interface-dummy/src/test/java/net/hypki/temp/AppTest.java b/chess-java-interface-dummy/src/test/java/net/hypki/temp/AppTest.java new file mode 100644 index 0000000..70f0571 --- /dev/null +++ b/chess-java-interface-dummy/src/test/java/net/hypki/temp/AppTest.java @@ -0,0 +1,38 @@ +package net.hypki.temp; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/chess-java-interface/pom.xml b/chess-java-interface/pom.xml new file mode 100644 index 0000000..7742a7e --- /dev/null +++ b/chess-java-interface/pom.xml @@ -0,0 +1,18 @@ + + 4.0.0 + net.hypki.temp + temp + jar + 0.1.0 + temp + http://maven.apache.org + + + junit + junit + 3.8.1 + test + + + diff --git a/chess-java-interface/src/main/java/net/hypki/wmi/oop/chess/ChessInterface.java b/chess-java-interface/src/main/java/net/hypki/wmi/oop/chess/ChessInterface.java new file mode 100644 index 0000000..d761246 --- /dev/null +++ b/chess-java-interface/src/main/java/net/hypki/wmi/oop/chess/ChessInterface.java @@ -0,0 +1,11 @@ +package net.hypki.wmi.oop.chess; + +/** + * Interface for chess programs for the classes 'Programowanie obiektowe' for Java language + * + */ +public interface ChessInterface { + public String nextMove(String opponentMove); + + public void printBoard(); +} diff --git a/chess-match/pom.xml b/chess-match/pom.xml new file mode 100644 index 0000000..7742a7e --- /dev/null +++ b/chess-match/pom.xml @@ -0,0 +1,18 @@ + + 4.0.0 + net.hypki.temp + temp + jar + 0.1.0 + temp + http://maven.apache.org + + + junit + junit + 3.8.1 + test + + + diff --git a/chess-match/src/main/java/net/hypki/wmi/oop/chess/ChessMatchMain.java b/chess-match/src/main/java/net/hypki/wmi/oop/chess/ChessMatchMain.java new file mode 100644 index 0000000..913630a --- /dev/null +++ b/chess-match/src/main/java/net/hypki/wmi/oop/chess/ChessMatchMain.java @@ -0,0 +1,33 @@ +package net.hypki.wmi.oop.chess; + +import net.hypki.wmi.oop.chess.dummy.BasicStudent; + +public class ChessMatchMain { + public static void main(String[] args) { + System.out.println("Preparing chess interface..."); + + ChessInterface student1White = new BasicStudent(); + ChessInterface student2Black = new BasicStudent(); + + String nextMove = null; + while (true) { + nextMove = student1White.nextMove(null); + + if (nextMove == null) + break; + + nextMove = student2Black.nextMove(nextMove); + + if (nextMove == null) + break; + } + + System.out.println("Match finished!"); + + System.out.println("Student1 board:"); + student1White.printBoard(); + + System.out.println("Student2 board:"); + student2Black.printBoard(); + } +} diff --git a/chess-match/src/test/java/net/hypki/temp/AppTest.java b/chess-match/src/test/java/net/hypki/temp/AppTest.java new file mode 100644 index 0000000..70f0571 --- /dev/null +++ b/chess-match/src/test/java/net/hypki/temp/AppTest.java @@ -0,0 +1,38 @@ +package net.hypki.temp; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/prosty-projekt-obiektowy-uwagi.txt b/prosty-projekt-obiektowy-uwagi.txt new file mode 100644 index 0000000..70bfbfc --- /dev/null +++ b/prosty-projekt-obiektowy-uwagi.txt @@ -0,0 +1,2 @@ +- każda klasa - osobny plik +- do gita nie wrzucamy skompilowanych plików \ No newline at end of file diff --git a/python/net/hypki/Figure.py b/python/net/hypki/Figure.py index 7be47bc..cff5188 100644 --- a/python/net/hypki/Figure.py +++ b/python/net/hypki/Figure.py @@ -11,7 +11,7 @@ class Figure(): __name = ''; - def __init__(self, newName = 'Default __name'): + def __init__(self, newName = 'Default name'): ''' Constructor ''' diff --git a/python/net/hypki/Main.py b/python/net/hypki/Main.py index ab1c9cb..79d2a3a 100644 --- a/python/net/hypki/Main.py +++ b/python/net/hypki/Main.py @@ -9,10 +9,11 @@ from net.hypki.Square import Square if __name__ == '__main__': f = Figure() f.__name = "New name" + print(str(f)) + print(f) + print(f.get_name()) f2 = Figure('Another name') - - print(str(f)) print(str(f2)) s1 = Square('Square1')