'Added first version of chess interface;'

This commit is contained in:
Arkadiusz Hypki 2023-05-09 16:05:40 +02:00
parent c6536762d1
commit 9a5cffb92c
12 changed files with 206 additions and 3 deletions

10
.gitignore vendored
View File

@ -1,3 +1,13 @@
bin bin
python/net/__pycache__ python/net/__pycache__
python/net/hypki/__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

View File

@ -0,0 +1,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.hypki.temp</groupId>
<artifactId>temp</artifactId>
<packaging>jar</packaging>
<version>0.1.0</version>
<name>temp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -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");
}
}

View File

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

View File

@ -0,0 +1,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.hypki.temp</groupId>
<artifactId>temp</artifactId>
<packaging>jar</packaging>
<version>0.1.0</version>
<name>temp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

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

18
chess-match/pom.xml Normal file
View File

@ -0,0 +1,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.hypki.temp</groupId>
<artifactId>temp</artifactId>
<packaging>jar</packaging>
<version>0.1.0</version>
<name>temp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

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

View File

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

View File

@ -0,0 +1,2 @@
- każda klasa - osobny plik
- do gita nie wrzucamy skompilowanych plików

View File

@ -11,7 +11,7 @@ class Figure():
__name = ''; __name = '';
def __init__(self, newName = 'Default __name'): def __init__(self, newName = 'Default name'):
''' '''
Constructor Constructor
''' '''

View File

@ -9,10 +9,11 @@ from net.hypki.Square import Square
if __name__ == '__main__': if __name__ == '__main__':
f = Figure() f = Figure()
f.__name = "New name" f.__name = "New name"
print(str(f))
print(f)
print(f.get_name())
f2 = Figure('Another name') f2 = Figure('Another name')
print(str(f))
print(str(f2)) print(str(f2))
s1 = Square('Square1') s1 = Square('Square1')