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]
3 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]3 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
The word Only is absolute or qualified
Semenov [28]

The word "only" is absolute.

5 0
3 years ago
Read 2 more answers
Henry bought a new card for capturing television on his computer. When he finished going through the packaging, though, he found
viva [34]

Answer:

reclamar

Explanation:

entonces tiens q ir a la misma tienda

6 0
3 years ago
Kylee needs to ensure that if a particular client sends her an email while she is on vacation, the email is forwarded to a cowor
STALIN [3.7K]

Answer: Configure a response for external senders.

Explanation:

Since Kylee wants to ensure that when a particular client sends her an email while she is on vacation, then the email will be forwarded to a coworker for immediate handling, then she should configure a response for external senders.

It should be noted that the response will not be configured for internal senders as it isn't from a co-worker but rather meant for a client. Therefore, the correct option is A.

6 0
3 years ago
Which tab automatically becomes available after inserting a text box? Drawing Tools Insert Text Box Tools Shape Tools
In-s [12.5K]

Answer:

insert text box

Explanation:

6 0
3 years ago
Read 2 more answers
Which of the following is a requirement for the Safety Data Sheet (SDS)?​
Natasha_Volkova [10]
What are the options?
4 0
3 years ago
Other questions:
  • Which of the following is NOT something you can specify in the bullets and numbering dialog box?
    8·1 answer
  • When might be the best time to start saving for retirement?
    11·2 answers
  • What is information associated with a document to help describe that document called?
    12·1 answer
  • Ben pays his mobile bills, watches movies, and shops online using the Internet. Which internet activity does he perform?
    13·2 answers
  • Why computer literacy is vital to access in business work
    7·1 answer
  • In order to enhance the training experience and emphasize the core security goals and mission, it is recommended that the execut
    5·1 answer
  • Which local folder temporarily stores all outgoing emails until the email program successfully sends them to a recipient?
    8·2 answers
  • Why When I change my pfp It be blurry and it be ugly- if you know what I mean :c
    15·2 answers
  • What is software? Why is it needed?​
    6·1 answer
  • Please help……Your friend is taking images from all over the internet without giving credit to the sources. He tells you that it’
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!