1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Oliga [24]
2 years ago
13

Can someone who is skilled at coding create me a Java chess game. Please don't copy from online source codes. Make it original t

hanks! :D
Computers and Technology
1 answer:
enot [183]2 years ago
8 0

copy this and fill in the blanks so you can change it up a bit



--------------------------------------------------------------------------------------------------------------

public class Game {

   private Board board = new Board();

   private Player white;

   private Player black;

   public Game() {

       super();

   }

   public void setColorWhite(Player player) {

       this.white = player;

   }

   public void setColorBlack(Player player) {

       this.black = player;

   }

   public Board getBoard() {

       return board;

   }

   public void setBoard(Board board) {

       this.board = board;

   }

   public Player getWhite() {

       return white;

   }

   public void setWhite(Player white) {

       this.white = white;

   }

   public Player getBlack() {

       return black;

   }

   public void setBlack(Player black) {

       this.black = black;

   }

   public boolean initializeBoardGivenPlayers() {

       if(this.black == null || this.white == null)

           return false;

       this.board = new Board();

       for(int i=0; i<black.getPieces().size(); i++){

           board.getSpot(black.getPieces().get(i).getX(), black.getPieces().get(i).getY()).occupySpot(black.getPieces().get(i));

       }

       return true;

   }

}

Player.java

public class Player {

   public final int PAWNS = 8;

   public final int BISHOPS = 2;

   public final int ROOKS = 2;

   public boolean white;

   private List<Piece> pieces = new ArrayList<>();

   public Player(boolean white) {

       super();

       this.white = white;

   }

   public List<Piece> getPieces() {

       return pieces;

   }

   public void initializePieces(){

       if(this.white == true){

           for(int i=0; i<PAWNS; i++){ // draw pawns

               pieces.add(new Pawn(true,i,2));

           }

           pieces.add(new Rook(true, 0, 0));

           pieces.add(new Rook(true, 7, 0));

           pieces.add(new Bishop(true, 2, 0));

           pieces.add(new Bishop(true, 5, 0));

           pieces.add(new Knight(true, 1, 0));

           pieces.add(new Knight(true, 6, 0));

           pieces.add(new Queen(true, 3, 0));

           pieces.add(new King(true, 4, 0));

       }

       else{

           for(int i=0; i<PAWNS; i++){ // draw pawns

               pieces.add(new Pawn(true,i,6));

           }

           pieces.add(new Rook(true, 0, 7));

           pieces.add(new Rook(true, 7, 7));

           pieces.add(new Bishop(true, 2, 7));

           pieces.add(new Bishop(true, 5, 7));

           pieces.add(new Knight(true, 1, 7));

           pieces.add(new Knight(true, 6, 7));

           pieces.add(new Queen(true, 3, 7));

           pieces.add(new King(true, 4, 7));

       }

   }

}

Board.java

public class Board {

   private Spot[][] spots = new Spot[8][8];

   public Board() {

       super();

       for(int i=0; i<spots.length; i++){

           for(int j=0; j<spots.length; j++){

               this.spots[i][j] = new Spot(i, j);

           }

       }

   }

   public Spot getSpot(int x, int y) {

       return spots[x][y];

   }

}

You might be interested in
A direct-mapped cache holds 64KB of useful data (not including tag or control bits). Assuming that the block size is 32-byte and
Cerrena [4.2K]

Answer:

A) Number of bits for byte = 6 bits

B) number of bits for index = 17 bits

C) number of bits for tag = 15 bits

Explanation:

Given data :

cache size = 64 kB

block size = 32 -byte

block address = 32 -bit

number of blocks in cache memory  

cache size / block size = 64 kb / 32 b = 2^11 hence the number of blocks in cache memory = 11 bits = block offset

A) Number of bits for byte

log _{2} (6)^2 = 6  bits

B) number of bits for index

block offset + byte number

= 11 + 6 = 17 bits

c ) number of bits for tag

= 32 - number of bits for index

= 32 - 17 = 15 bits

5 0
3 years ago
Sarah is starting her first job at the local ice cream shop. what can Sarah do to make a good impression on her first day of wor
nikdorinn [45]
Dress appropriate and have a good attitude
7 0
2 years ago
Read 2 more answers
Can a result that contains road maps for European countries have a highly meets rating
Mice21 [21]

Đápán3e

Explanation:

8 0
3 years ago
What acronym is used to reference the data link sublayer that identifies the network layer protocol encapsulated in the frame?
juin [17]

Logical Link Control is the data link sublayer that identifies the network layer protocol encapsulated in the frame. The acronym of Logical Link Control is LLC.

Therefore, the answer is LLC.

7 0
3 years ago
Which layer enables the receving node to send an acknowledgement?
Svetllana [295]

Answer:

Data link layer enables the receiving node to send an acknowledgement.

Explanation:

The data link has following function;

1 it send the acknowledgement to the node because for the reliable    transmission.

2.Data link layer provides the interface to the network layer.

3.it regulate  the flow of data.

4.It control the transmission error.

The important function of data link layer it created packets of the data to send the packets in guarantee manner for giving the acknowledgement to the node that data is received successfully.

6 0
3 years ago
Other questions:
  • When an IRET instruction is executed, what actiontakes place?
    5·1 answer
  • ________ is digital textual information that can be stored, manipulated, and transmitted by electronic devices.
    7·1 answer
  • Which term describes the process by which light passes through an object or a medium.
    7·2 answers
  • In the code segment below, assume that the int variable n has been properly declared and initialized. The code segment is intend
    5·1 answer
  • A friend complains that she is always running out of money even though she “never buys anything expensive.” What advice would yo
    5·2 answers
  • Program ____ use graphical symbols and relational operators (such as &lt; for "less than" and = for "equal to") to portray the s
    8·1 answer
  • I had tried to turn on Linux on the Chromebook but it's not working
    11·2 answers
  • Make a list of five primary raw materials, for each one, indicate and industrial material that is created from it
    10·2 answers
  • Which information can you apply to every page of your document with the page layout options?
    9·1 answer
  • Pleasee helpppppppppppppppppppppp me!
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!