Implement move the following way.  public int[] walk(int... stepCounts) { // Implement the logic for walking the players returnnewint[0]; }   public class WalkingBoardWithPlayers extends WalkingBoard{ privatePlayer[] players; privateintround; publicstaticfinalintSCORE_EACH_STEP=13; publicWalkingBoardWithPlayers(int[][] board, intplayerCount) { super(board); initPlayers(playerCount); } publicWalkingBoardWithPlayers(intsize, intplayerCount) { super(size); initPlayers(playerCount); } privatevoidinitPlayers(intplayerCount) { if(playerCount <2){ thrownewIllegalArgumentException("Player count must be at least 2"); } else { this.players=newPlayer[playerCount]; this.players[0] =newMadlyRotatingBuccaneer(); for (inti=1; i < playerCount; i++) { this.players[i] =newPlayer(); } } }   package walking.game.player; import walking.game.util.Direction; public class Player{ privateintscore; protectedDirectiondirection=Direction.UP; publicPlayer() {} publicintgetScore() { return score; } publicDirectiongetDirection() { return direction; } publicvoidaddToScore(intscore) { this.score+= score; } publicvoidturn() { // Implement the logic for turning the player } } The players get to play in order. After the last player, the first one is up again. The player begins by calling turn() once. When turning, the player’s direction changes to the next Direction (or to the first one if the current one is the last). The MadlyRotatingBuccaneer is a bit different: it considers how many times he has come to play already, and turns that much. So, when he plays for the first time, he doesn’t change his direction at all. The next time he’s playing, he turns just once, like a regular Player. Then he turns back a full 180°. And so on… After turning, he takes as many steps forwards (in the direction that he’s facing) as the next element in the argument array tells him to. As the second argument to moveAndSet, use the number of steps taken in total during this execution of move but no more than SCORE_EACH_STEP. Here, steps that would leave the board count, too. Increase the score of the current player by the value read from the board position. The return value contains the scores of the players in an array.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question
100%

Implement move the following way. 

public int[] walk(int... stepCounts) {
// Implement the logic for walking the players
returnnewint[0];
}
 
public class WalkingBoardWithPlayers extends WalkingBoard{
privatePlayer[] players;
privateintround;
publicstaticfinalintSCORE_EACH_STEP=13;

publicWalkingBoardWithPlayers(int[][] board, intplayerCount) {
super(board);
initPlayers(playerCount);
}
publicWalkingBoardWithPlayers(intsize, intplayerCount) {
super(size);
initPlayers(playerCount);
}
privatevoidinitPlayers(intplayerCount) {
if(playerCount <2){
thrownewIllegalArgumentException("Player count must be at least 2");
} else {
this.players=newPlayer[playerCount];
this.players[0] =newMadlyRotatingBuccaneer();
for (inti=1; i < playerCount; i++) {
this.players[i] =newPlayer();
}
}
}
 
package walking.game.player;
import walking.game.util.Direction;

public class Player{
privateintscore;
protectedDirectiondirection=Direction.UP;

publicPlayer() {}

publicintgetScore() {
return score;
}

publicDirectiongetDirection() {
return direction;
}

publicvoidaddToScore(intscore) {
this.score+= score;
}

publicvoidturn() {
// Implement the logic for turning the player
}
}
  • The players get to play in order. After the last player, the first one is up again.
  • The player begins by calling turn() once.
    • When turning, the player’s direction changes to the next Direction (or to the first one if the current one is the last).
    • The MadlyRotatingBuccaneer is a bit different: it considers how many times he has come to play already, and turns that much.
      • So, when he plays for the first time, he doesn’t change his direction at all.
      • The next time he’s playing, he turns just once, like a regular Player.
      • Then he turns back a full 180°.
      • And so on…
  • After turning, he takes as many steps forwards (in the direction that he’s facing) as the next element in the argument array tells him to.
    • As the second argument to moveAndSet, use the number of steps taken in total during this execution of move but no more than SCORE_EACH_STEP.
      • Here, steps that would leave the board count, too.
    • Increase the score of the current player by the value read from the board position.
  • The return value contains the scores of the players in an array.
 
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Depth First Search
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education