JAVA

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

JAVA

Post by answerhappygod »

JAVA
Java 1
Java 1 (360.62 KiB) Viewed 29 times
6) The game Othello is played on an 8×8 board of squares, each of which is either empty or it holds a Black piece or a White piece. On Black's move it is legal for them to place a new piece on an empty square x, y iff there is a straight line of one or more White pieces from x, y to another square holding a Black piece. For example, on this board: O

it is legal for Black to place a piece on any of the squares marked by a small circle: (3,1), or (4,1), or (4,2), or (6,3), or (3,5), or (5,5). Write the following method. (10 marks) // returns true iff Black can place a piece at x,y on board public boolean canPlaceAt (int x, int y, int[] [] board) board is an 8×8 array where each element is O if the corresponding square is empty, 1 if it is occupied by a Black piece, and -1 if it is occupied by a White piece. Squares are numbered 0..7 up and across from the bottom-left-hand corner. You will probably find it helpful to define a private helper method that checks whether the new piece makes a line in one direction from x, y.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply