Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions clean_code_projects/_1_project_requirements_chess/ChessGame.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<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>com.howtodoinjava</groupId>
<artifactId>JavaExeDemo</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>JavaExeDemo</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.7.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>shaded</shadedClassifierName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.howtodoinjava.Main</mainClass>
</transformer>
</transformers>
</configuration>
</plugin>
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>1.5.1</version>
<executions>
<execution>
<id>l4j-clui</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>gui</headerType>
<jar>${project.build.directory}/${artifactId}-${version}-shaded.jar</jar>
<outfile>${project.build.directory}/howtodoinjava.exe</outfile>
<downloadUrl>http://java.com/download</downloadUrl>
<classPath>
<mainClass>com.howtodoinjava.ApplicationMain</mainClass>
<preCp>anything</preCp>
</classPath>
<icon>application.ico</icon>
<jre>
<minVersion>1.6.0</minVersion>
<jdkPreference>preferJre</jdkPreference>
</jre>
<versionInfo>
<fileVersion>1.0.0.0</fileVersion>
<txtFileVersion>${project.version}</txtFileVersion>
<fileDescription>${project.name}</fileDescription>
<copyright>2012 howtodoinjava.com</copyright>
<productVersion>1.0.0.0</productVersion>
<txtProductVersion>1.0.0.0</txtProductVersion>
<productName>${project.name}</productName>
<companyName>howtodoinjava.com</companyName>
<internalName>howtodoinjava</internalName>
<originalFilename>howtodoinjava.exe</originalFilename>
</versionInfo>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: StartGame

Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,46 @@ public class ChessBoard {
public static int MAX_BOARD_WIDTH = 7;
public static int MAX_BOARD_HEIGHT = 7;

private Pawn[][] pieces;
public Pawn[][] pieces;

public ChessBoard() {
pieces = new Pawn[MAX_BOARD_WIDTH][MAX_BOARD_HEIGHT];
pieces = new Pawn[MAX_BOARD_WIDTH+1][MAX_BOARD_HEIGHT+1];

}

public void Add(Pawn pawn, int xCoordinate, int yCoordinate, PieceColor pieceColor) {
throw new UnsupportedOperationException("Need to implement ChessBoard.add()");
public void updatePiecePositionOnChessBoard(Pawn pawn, int xCoordinate, int yCoordinate) {
pawn.setXCoordinate(xCoordinate);
pawn.setYCoordinate(yCoordinate);
pieces[xCoordinate][yCoordinate] = pawn;
}

public void addPawn(Pawn pawn, int xCoordinate, int yCoordinate, PieceColor pieceColor) {
if (IsLegalBoardPosition(xCoordinate, yCoordinate) &&
(isValidRow(yCoordinate,PieceColor.WHITE) || isValidRow(yCoordinate,PieceColor.BLACK)) &&
isFreePosition(xCoordinate,yCoordinate)){
pawn.setXCoordinate(xCoordinate);
pawn.setYCoordinate(yCoordinate);
pawn.setChessBoard(this);
pawn.setPieceColor(pieceColor);
pieces[xCoordinate][yCoordinate] = pawn;
}
else{
throw new UnsupportedOperationException("Exception at: IsLegalBoardPosition()/isValidRow()/isFreePosition()");
}
}

public boolean isFreePosition(int xCoordinate, int yCoordinate){
return pieces[xCoordinate][yCoordinate] == null;
}

public boolean isValidRow(int yCoordinate, PieceColor color){
if (color == color.WHITE) {
return yCoordinate == 0 || yCoordinate == 1;
}
return yCoordinate == MAX_BOARD_HEIGHT - 1 || yCoordinate == MAX_BOARD_HEIGHT;
}

public boolean IsLegalBoardPosition(int xCoordinate, int yCoordinate) {
throw new UnsupportedOperationException("Need to implement ChessBoard.IsLegalBoardPosition()");
return xCoordinate >= 0 && yCoordinate >= 0 && xCoordinate <= MAX_BOARD_WIDTH && yCoordinate <= MAX_BOARD_HEIGHT;
}
}
Loading