Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#JAVA Create a project. Copy your ChessPiece class. Create a new class titled ChessBoard that contains A private multi-dimensional array of containing the squares of

#JAVA

Create a project.

Copy your ChessPiece class.

Create a new class titled ChessBoard that contains

A private multi-dimensional array of containing the squares of the chess board

Getter and Setter methods for putting a chess piece into that array (yes, similar to the ones in ChessPiece.)

Include in the Setter methods some basic collision detection. Specifically, do NOT allow a2 piece to occupy a square. This will form the basis for our game "rules" later on.

Create a new application titled setupChessBoard that contains your main statement.

Populate the ChessBoard with your ChessPiece elements

Print out the current location of your ChessPieces on your board... a simple list is fine.

Chess Piece Class:

class ChessPiece { private int row,col; private String colorChessPiece, nameChesspiece;

public int getPositionRow() //getting position of row { return row; } public int getPositionColumn() //getting position of column { return col; } public String getColor() //getting color of a chess piece { return colorChessPiece; } public String getPieceType() //getting name of a chess piece { return nameChesspiece; } public void setPosition(int x, int y) //setting position of a chess piece { row = x; col = y; } public void setColor(String color) //setting color of a chess piece { colorChessPiece = color; } public void setPieceType(String name) //setting name of a chess piece { nameChesspiece = name; } public void printInfo() //printing all the details of a chess piece { System.out.println("Chess Piece Details-"); System.out.println("---------------------"); System.out.println("Position: " + getPositionRow() + "," + getPositionColumn()); System.out.println("Color: " + getColor()); System.out.println("Name: " + getPieceType() + " "); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions

Question

1. Explain why evaluation is important.

Answered: 1 week ago