Error fixing attempt - 1
This commit is contained in:
@@ -3,20 +3,15 @@ package com.truecaller.truecallerassignment.backend.controller;
|
|||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.truecaller.truecallerassignment.backend.entities.Tile;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class TruecallerAssignmentController {
|
public class TruecallerAssignmentController {
|
||||||
private static final String template = "Hello, %s!";
|
private static final String template = "Hello, %s!";
|
||||||
private final AtomicLong counter = new AtomicLong();
|
private final AtomicLong counter = new AtomicLong();
|
||||||
|
|
||||||
@GetMapping("/hello-world")
|
@GetMapping("/")
|
||||||
@ResponseBody
|
public String index() {
|
||||||
public Tile sayHello(@RequestParam(name="name", required=false, defaultValue="Stranger") String name) {
|
return "Hello there! I'm running.";
|
||||||
return new Tile(4, 5, false);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -61,27 +61,27 @@ public class Tile {
|
|||||||
* @return List<Tile> list of all positions possible from given tile
|
* @return List<Tile> list of all positions possible from given tile
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void generateAllowedMoves() {
|
// public void generateAllowedMoves() {
|
||||||
List<Tile> allowedMoves = new ArrayList<Tile>();
|
// List<Tile> allowedMoves = new ArrayList<Tile>();
|
||||||
if (row > 3)
|
// if (row > 3)
|
||||||
allowedMoves.add(getTile(row - 3, column));
|
// allowedMoves.add(getTile(row - 3, column));
|
||||||
if (row < 8)
|
// if (row < 8)
|
||||||
allowedMoves.add(getTile(row + 3, column));
|
// allowedMoves.add(getTile(row + 3, column));
|
||||||
if (column > 3)
|
// if (column > 3)
|
||||||
allowedMoves.add(getTile(row, column - 3));
|
// allowedMoves.add(getTile(row, column - 3));
|
||||||
if (column < 8)
|
// if (column < 8)
|
||||||
allowedMoves.add(getTile(row, column + 3));
|
// allowedMoves.add(getTile(row, column + 3));
|
||||||
if (row > 2 && column > 2)
|
// if (row > 2 && column > 2)
|
||||||
allowedMoves.add(getTile(row - 2, column - 2));
|
// allowedMoves.add(getTile(row - 2, column - 2));
|
||||||
if (row > 2 && column < 9)
|
// if (row > 2 && column < 9)
|
||||||
allowedMoves.add(getTile(row - 2, column + 2));
|
// allowedMoves.add(getTile(row - 2, column + 2));
|
||||||
if (row < 9 && column > 2)
|
// if (row < 9 && column > 2)
|
||||||
allowedMoves.add(getTile(row + 2, column - 2));
|
// allowedMoves.add(getTile(row + 2, column - 2));
|
||||||
if (row < 9 && column < 9)
|
// if (row < 9 && column < 9)
|
||||||
allowedMoves.add(getTile(row + 2, column + 2));
|
// allowedMoves.add(getTile(row + 2, column + 2));
|
||||||
|
//
|
||||||
this.allowedMoves = allowedMoves.stream().filter(tile -> !tile.visited).collect(Collectors.toList());
|
// this.allowedMoves = allowedMoves.stream().filter(tile -> !tile.visited).collect(Collectors.toList());
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|||||||
Reference in New Issue
Block a user