I need the solution in java
Task Java English Files solution.java X 1 // you can also use imports, for example: 2 // import java.util.*; 2 task2 D solution.java test-input.txt 4 5 // you can write to stdout for debugging purposes, e.g. // System.out.println(“this is a debug message”); Pawns in checkers move diagonally. The pawn always moves one step in the up-right or up-left direction. If Jafar’s pawn moves and its target field is occupied by one of Aladdin’s pawns, Aladdin’s pawn can be beaten: Jafar’s pawn leaps over Aladdin’s pawn, taking two steps in the chosen direction and removing Aladdin’s pawn from the board. Jafar can beat Aladdin’s pawn in this way only when the field beyond Aladdin’s pawn is empty. 7. class Solution { 8 public int solution(String[] B) { // write your code in Java SE B 11. After beating Aladdin’s pawn, Jafar can continue his turn and make another move, but only if he will again beat another one of Aladdin’s pawns. Of course, after this additional move, Jafar can continue his turn again by beating another of Aladdin’s pawns, and so on for as long as there are further pawns to beat. When it is no longer possible to beat one of Aladdin’s pawns, Jafar’s turn ends. For example, in the situation depicted below (where Jafar’s pawn is white and Aladdin’s pawns are black): You will see save status here Test Output Run Tests Jafar can beat one of Aladdin’s pawns by moving his pawn two steps in the up-right direction, and then he can make an additional move, beating another of Aladdin’s pawns in the up-left direction. After this move there are no more of Aladdin’s pawns available to beat, so Jafar’s turn ends, In the following situations: Task Java English Files D solution.java x 1 1 you can also use imports, for example: 2 / import java.util.*; 2 task2 solution.java test-input.txt 4 5 // you can write to stdout for debugging purposes, 6.9. // System.out.println(“this is a debug message”); Jafar cannot beat Aladdin’s pawn. In the first case, the field two steps in the up-right direction from Jafar’s pawn (white) is occupied by one of Aladdin’s pawns (black); in the second case, this field is placed outside the board in the third case, Jafar’s pawn cannot move directly upwards: and finally, in the fourth case, Jafar’s pawn cannot move in the down-right, direction. 7 – class Solution { B public int solution(String[] B) { 9 // write your code in Java SE 8 10 } 11 ) What is the maximum number of pawns owned by Aladdin that Jafar can beat in his turn? Write a function: class Solution { public int solution(String[ 1 B); } which, given a square board of Nx N size describing Aladdin’s and Jafar’s pawns, returns the maximum number of pawns Jafar can beat in one turn, If none of Aladdin’s pawns can be beaten, the function should return o. Jafar’s pawn is described by the ‘o’ character, Aladdin’s pawns by x characters and empty fields by’.'(dots). The board is described from top to bottom and from left to right. You will see save status here Test Output Run Tests For example, given: B[0] = “..X…” B[1] = “……” B[2] = “…. .” B[3] = B[4] = “..X.X.” B51 – “…0..” the function should return 2 (Jafar can beat Aladdin’s pawn in the up-right direction and then another one in the up-left direction), Given: B101 = “….” Task Java – English Files D solution.java X 1 / you can also use imports, for example: 2 // import java.util.*. task2 If none of Aladdin’s pawns can be beaten, the function should return o. solution.java test-input.txt 4 5 // you can write to stdout for debugging purposes, e.g. // System.out.println(“this is a debug message”); Jafar’s pawn is described by the ‘o’ character, Aladdin’s pawns by ‘x’ characters and empty fields by’.'(dots). The board is described from top to bottom and from left to right. 7″ class Solution { 8 public int solution (String[] B) { // write your code in Java SE 8 10 11 ] 12 For example, given: B[0] = “.. …” B[i] = “……” B[2] = “…. .” B[3] – “. ….” B[4] = “..X.X.” B[5] = “…0..” the function should return 2 (Jafar can beat Aladdin’s pawn in the up-right direction and then another one in the up-left direction). Given: B[O) – B[1] = B[2] = B[3] = B[4] = “X… ” “. …” “..0..” “…X.” “…..” You will see save status here the function should return O. Test Output Run Tests Assume that: . N is an integer within the range (1..30]; • all strings in B consist only of the following characters: “. “X’ and/or “o”; • the board is N x N square; the board contains exactly one pawn owned by Jafar. In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment. Show transcribed image text Task Java English Files solution.java X 1 // you can also use imports, for example: 2 // import java.util.*; 2 task2 D solution.java test-input.txt 4 5 // you can write to stdout for debugging purposes, e.g. // System.out.println(“this is a debug message”); Pawns in checkers move diagonally. The pawn always moves one step in the up-right or up-left direction. If Jafar’s pawn moves and its target field is occupied by one of Aladdin’s pawns, Aladdin’s pawn can be beaten: Jafar’s pawn leaps over Aladdin’s pawn, taking two steps in the chosen direction and removing Aladdin’s pawn from the board. Jafar can beat Aladdin’s pawn in this way only when the field beyond Aladdin’s pawn is empty. 7. class Solution { 8 public int solution(String[] B) { // write your code in Java SE B 11. After beating Aladdin’s pawn, Jafar can continue his turn and make another move, but only if he will again beat another one of Aladdin’s pawns. Of course, after this additional move, Jafar can continue his turn again by beating another of Aladdin’s pawns, and so on for as long as there are further pawns to beat. When it is no longer possible to beat one of Aladdin’s pawns, Jafar’s turn ends. For example, in the situation depicted below (where Jafar’s pawn is white and Aladdin’s pawns are black): You will see save status here Test Output Run Tests Jafar can beat one of Aladdin’s pawns by moving his pawn two steps in the up-right direction, and then he can make an additional move, beating another of Aladdin’s pawns in the up-left direction. After this move there are no more of Aladdin’s pawns available to beat, so Jafar’s turn ends, In the following situations:
Task Java English Files D solution.java x 1 1 you can also use imports, for example: 2 / import java.util.*; 2 task2 solution.java test-input.txt 4 5 // you can write to stdout for debugging purposes, 6.9. // System.out.println(“this is a debug message”); Jafar cannot beat Aladdin’s pawn. In the first case, the field two steps in the up-right direction from Jafar’s pawn (white) is occupied by one of Aladdin’s pawns (black); in the second case, this field is placed outside the board in the third case, Jafar’s pawn cannot move directly upwards: and finally, in the fourth case, Jafar’s pawn cannot move in the down-right, direction. 7 – class Solution { B public int solution(String[] B) { 9 // write your code in Java SE 8 10 } 11 ) What is the maximum number of pawns owned by Aladdin that Jafar can beat in his turn? Write a function: class Solution { public int solution(String[ 1 B); } which, given a square board of Nx N size describing Aladdin’s and Jafar’s pawns, returns the maximum number of pawns Jafar can beat in one turn, If none of Aladdin’s pawns can be beaten, the function should return o. Jafar’s pawn is described by the ‘o’ character, Aladdin’s pawns by x characters and empty fields by’.'(dots). The board is described from top to bottom and from left to right. You will see save status here Test Output Run Tests For example, given: B[0] = “..X…” B[1] = “……” B[2] = “…. .” B[3] = B[4] = “..X.X.” B51 – “…0..” the function should return 2 (Jafar can beat Aladdin’s pawn in the up-right direction and then another one in the up-left direction), Given: B101 = “….”
Task Java – English Files D solution.java X 1 / you can also use imports, for example: 2 // import java.util.*. task2 If none of Aladdin’s pawns can be beaten, the function should return o. solution.java test-input.txt 4 5 // you can write to stdout for debugging purposes, e.g. // System.out.println(“this is a debug message”); Jafar’s pawn is described by the ‘o’ character, Aladdin’s pawns by ‘x’ characters and empty fields by’.'(dots). The board is described from top to bottom and from left to right. 7″ class Solution { 8 public int solution (String[] B) { // write your code in Java SE 8 10 11 ] 12 For example, given: B[0] = “.. …” B[i] = “……” B[2] = “…. .” B[3] – “. ….” B[4] = “..X.X.” B[5] = “…0..” the function should return 2 (Jafar can beat Aladdin’s pawn in the up-right direction and then another one in the up-left direction). Given: B[O) – B[1] = B[2] = B[3] = B[4] = “X… ” “. …” “..0..” “…X.” “…..” You will see save status here the function should return O. Test Output Run Tests Assume that: . N is an integer within the range (1..30]; • all strings in B consist only of the following characters: “. “X’ and/or “o”; • the board is N x N square; the board contains exactly one pawn owned by Jafar. In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment.
Expert Answer
Answer to Task Java English Files solution.java X 1 // you can also use imports, for example: 2 // import java.util.*; 2 task2 D s…