Skip to content

Instantly share code, notes, and snippets.

@anupamsharma
Created October 10, 2012 11:59
Show Gist options
  • Save anupamsharma/3865171 to your computer and use it in GitHub Desktop.
Save anupamsharma/3865171 to your computer and use it in GitHub Desktop.
Simple Multiplayer Chess Game...
public class AbstractPosition {}
protected class ChessPiece {
enum color
enum player
// not really needed
is_alive
protected boolean is_valid_move(int x1, int y1, int x2, int y2);
}
public class AbstractGameManager {
piece player1_pieces[];
piece player1_pieces[];
GameManager() {
}
public getCurrentSituation() {
}
public isMatchConcluded() {
}
public whoWon() {
}
public boolean move(player, positioin1, position2) {
}
}
/* Just have child classes with different implementations of is_valid_move */
protected class Horse extends ChessPiece {
protected boolean is_valid_move(int x1, int y1, int x2, int y2) {
// Some implementation
}
}
protected ChessBlock {
color
piece
has_piece()
get_piece()
set_piece()
}
.....
.....
....
public class ChessBoardManager {
public static final BLACK = True;
public static final WHITE = False;
public static ROW_LENGTH = 8;
ChessBlock chess_blocks[][];
piece player1_pieces[];
piece player1_pieces[];
ChessBoardManager() {
chess_blocks = new ChessBlock[ROW_LENGTH][ROW_LENGTH];
int row_counter = 0;
for(int row_counter=0; row_counter < ;) {
}
}
move(player, x1, x2, x3, x4) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment