GithubHelp home page GithubHelp logo

hibernaut / program-your-own-chess Goto Github PK

View Code? Open in Web Editor NEW

This project forked from psoder3/program-your-own-chess

0.0 0.0 0.0 62 KB

This Java project is designed to help students incorporate some of the things they've already learned with my code in order to create a fully-functional chess game. The user interface is already created. All the student must do is implement the canMove method for each type of piece.

Java 100.00%

program-your-own-chess's Introduction

Program-Your-Own-Chess

Purpose

Students will apply many of the concepts they've already learned in order to add on to my code and create a fully-functional chess game.

Current Behavior of the Project

The user interface is already created. There is a board and 32 pieces. Feel free to replace the piece images with your own.

The white pieces go first and then the black pieces, and they continue to take turns.

The pieces can move anywhere right now. If the place they move to has a piece, that piece will be killed, even if it is the player's own piece.

Instructions

Your job is to program the game logic that restricts pieces from making illegal moves. You will implement the canMove method for the King, Queen, Bishop, Knight, Rook, and Pawn classes. Here is what the Pawn's canMove method looks like:

    @Override
    public boolean canMove(int destination_x, int destination_y)
    {
        // Remember: A pawn may only move towards the oponent's side of the board.
        // If the pawn has not moved yet in the game, for its first move it can 
        // move two spaces forward. Otherwise, it may only move one space. 
        // When not attacking it may only move straight ahead.
        // When attacking it may only move space diagonally forward

                // WRITE CODE HERE
        
                
                
        return true;
    }

That method will return true if the desired moved is allowed and false otherwise. You will need to use the following methods in order to complete this:

/**
 *  put in the x and y values representing a position on the board (0-7,0-7)
 *  and this method returns the piece that is at that position. If there 
 *  is no piece at that position, this method returns the null.) 
 */
Piece Board.getPiece(int x, int y) 

/**
 *  this method tells you what a specific piece's x value is on the board 
 *  (0 at the left, all the way to 7 at the right)
 */
int Piece.getX()

/**
 *  this method tells you what a specific piece's y value is on the board 
 *  (0 at the top, all the way to 7 at the bottom)
 */
int Piece.getY()

/**
 *  this method returns true if the piece is white and false otherwise
 */
boolean Piece.isWhite()

/**
 *  this method returns true if the piece is black and false otherwise
 */
boolean Piece.isBlack()

program-your-own-chess's People

Contributors

psoder3 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.