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
IDPSs can also help the organization protect its assets when its networks and systems are still exposed to ____________________
miss Akunina [59]

Answer:

The answer is "Known"

Explanation:

The network security tool also referred to as the IDPSs or Network Prevention Solution (NDPS), all organizations typically use IDPs to assess security concerns, detect security threats.  

  • It avoid breaches of security protocols by individuals, and it may also assist the company in protecting its assets.  
  • When its networks and systems either face security flaws or unable to respond to an evolving environment of risks, and other choices were incorrect because it can't be defined in the question.
3 0
3 years ago
1. in terms of technology, we often said to be living in the _____ age.???
sleet_krkn [62]
I think its the new age either that or end times
3 0
3 years ago
Read 2 more answers
Digital cameras always create great photographs. <br>True <br>False
Pavel [41]

True..they do take great photography..

8 0
3 years ago
Read 2 more answers
In what country did true printing first take place?
kow [346]
Germany. Johannes Guten in Mainz, Germany
7 0
3 years ago
Read 2 more answers
Which chart element provides the boundaries of the graphic?
slava [35]
If your choices are the following:
<span>A. Legend
B. Chart area
C. Slices
D. Chart elements

Then the answer is letter B. </span>Chart area is the boundary that contains all the chart and all its elements including the chart titles, legends, plot area, labels, etc. 
4 0
4 years ago
Other questions:
  • What's the full form of SEO?
    12·2 answers
  • To record your own audio, you must have _____.
    14·2 answers
  • Implement the Dining Philosophers problem (described on pages 167-170 in the textbook (chapter 2.5.1)). Create a Graphical User
    13·1 answer
  • Que significa DESFRAGMENTAR EL DISCO DURO?????
    14·1 answer
  • _______________ ________________ have human editors that evaluate, select, and organize websites into a hierarchy of categories.
    11·1 answer
  • Please can someone help my assignment.​
    13·1 answer
  • Drag the tiles to the correct boxes to complete the pairs.
    15·2 answers
  • How is video compression accomplished?
    14·1 answer
  • Which option is a real job title on the interactive media career pathway? A. Social networking specialist B. Information technol
    11·1 answer
  • What enforces the location in which an app can function by tracking the location of the mobile device?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!