'Added first version of chess interface;'
This commit is contained in:
parent
c6536762d1
commit
9a5cffb92c
10
.gitignore
vendored
10
.gitignore
vendored
@ -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
|
||||
|
18
chess-java-interface-dummy/pom.xml
Normal file
18
chess-java-interface-dummy/pom.xml
Normal 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>
|
@ -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");
|
||||
}
|
||||
}
|
@ -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 );
|
||||
}
|
||||
}
|
18
chess-java-interface/pom.xml
Normal file
18
chess-java-interface/pom.xml
Normal 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>
|
@ -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
18
chess-match/pom.xml
Normal 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>
|
@ -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();
|
||||
}
|
||||
}
|
38
chess-match/src/test/java/net/hypki/temp/AppTest.java
Normal file
38
chess-match/src/test/java/net/hypki/temp/AppTest.java
Normal 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 );
|
||||
}
|
||||
}
|
2
prosty-projekt-obiektowy-uwagi.txt
Normal file
2
prosty-projekt-obiektowy-uwagi.txt
Normal file
@ -0,0 +1,2 @@
|
||||
- każda klasa - osobny plik
|
||||
- do gita nie wrzucamy skompilowanych plików
|
@ -11,7 +11,7 @@ class Figure():
|
||||
|
||||
__name = '';
|
||||
|
||||
def __init__(self, newName = 'Default __name'):
|
||||
def __init__(self, newName = 'Default name'):
|
||||
'''
|
||||
Constructor
|
||||
'''
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user