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
1. Insert a Header that has the following in excel​
Fofino [41]

Answer:

Go to Insert and click on Text and underneth that click header and footor.

Explanation:

You can do a Header and Fotter in Excel. ALl you have to do if go in the document you are working in and you click on Instert tab and then click on Header and Fotter. It gives you an option to make a header for your excel wookbook.

7 0
3 years ago
Recursion occurs when a function (calls itself/ calls another function/ calls a function from the python standard library)
lesantik [10]

Answer:

Recursion is calling of a function from within that same function

5 0
3 years ago
Alexis received paychecks from both her jobs and she would like to deposit them. One check is for $62.88 and the other is $523.2
Karolina [17]

Answer:

something :}

Explanation:

have a good day

8 0
2 years ago
Assuming that the message variable contains the string "Happy holidays", the statement message.find("days"); returns a. -1b. 10c
katrin [286]

Answer:

Answer is b. 10                

Explanation:

The find() method is used to search the string for a specified value and searches the first occurrence of that value. It returns the position of that specified value. If the value is not found, this method returns -1.

Lets say we have a message variable that contains the string Happy holidays.

message = "Happy holidays"

We use the method find() to find days word from the Happy holidays string in the message variable.

The find() method will find the position of day.

If we look at the string Happy holidays we see that the word day is at the 10th position of the string.

H     1

a      2

p      3

p      4

y      5

h      6

o      7

l       8

i       9

d      10

a      11

y      12

s      13

So it is at 10th position so the statement

message.find("days")

returns 10

7 0
3 years ago
Energy requirements of analog and digital signals.
jek_recluse [69]
Analog signals require more energy.

Analog=Constant flowing modulated

Digital is bursts of on/off binary data.
8 0
3 years ago
Read 2 more answers
Other questions:
  • Your laptop doesn't have a serial port. what type of connector will your laptop require
    6·1 answer
  • Data means a group of numbers. <br> a. True<br> b. False
    7·1 answer
  • Graphs and charts are two different elements. True or False
    15·1 answer
  • Select the correct answer.
    6·1 answer
  • Tom's Art Supplies used to sell art supplies through mail order catalogs, but the company's order takers often had difficulty de
    9·1 answer
  • For any two documents x and z, define k(x, z) to equal the number of unique words that occur in both x and z (i.e., the size of
    15·1 answer
  • Which question about whale sharks is nonscientific?
    11·2 answers
  • Which is not one of the four criteria for proving the correctness of a logical pretest loop construct of the form: while B do S
    14·1 answer
  • What is the main difference between the ICD-10 annual revision released by the WHO and the ICD-10-CM/PCS annual revision release
    11·1 answer
  • A machine that converts energy to useful work.
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!