This is a test task for a backend developer from backbase.com.
The goal of this task is to implement a REST api to play Kalah game. Complete task description can be found in document.
- OpenJDK 11
./mvnw spring-boot:run
Field | Type | Read only | Comment |
---|---|---|---|
id | String | true | App will auto generate it. |
uri | String | true | Absolute url to Game REST resource. |
status | Integer | true | Map where each key is a string id of the Pit (1-based) and value is the current number of stones in this pit (also string). |
nextPlayer | Integer | true | The id of player who's turn is next. null for new created game. |
gameOver | Boolean | true | true if the game is over. |
POST /games
Example
curl \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-X POST http://127.0.0.1:8080/games
{
"id": "34490f2d-ddfc-44f0-9959-d5133d13b65a",
"uri": "http://127.0.0.1:8080/games/34490f2d-ddfc-44f0-9959-d5133d13b65a",
"status": {
"1": "6",
"2": "6",
"3": "6",
"4": "6",
"5": "6",
"6": "6",
"7": "0",
"8": "6",
"9": "6",
"10": "6",
"11": "6",
"12": "6",
"13": "6",
"14": "0"
},
"nextPlayer": null,
"gameOver": false
}
GET /games/{gameId}
Example
curl \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-X GET http://127.0.0.1:8080/games/34490f2d-ddfc-44f0-9959-d5133d13b65a
{
"id": "34490f2d-ddfc-44f0-9959-d5133d13b65a",
"uri": "http://127.0.0.1:8080/games/34490f2d-ddfc-44f0-9959-d5133d13b65a",
"status": {
"1": "6",
"2": "6",
"3": "6",
"4": "6",
"5": "6",
"6": "6",
"7": "0",
"8": "6",
"9": "6",
"10": "6",
"11": "6",
"12": "6",
"13": "6",
"14": "0"
},
"nextPlayer": null,
"gameOver": false
}
PUT /games/{gameId}/pits/{pitId}
Example
curl \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-X PUT http://127.0.0.1:8080/games/34490f2d-ddfc-44f0-9959-d5133d13b65a/pits/1
{
"id": "34490f2d-ddfc-44f0-9959-d5133d13b65a",
"uri": "http://127.0.0.1:8080/games/34490f2d-ddfc-44f0-9959-d5133d13b65a",
"status": {
"1": "0",
"2": "7",
"3": "7",
"4": "7",
"5": "7",
"6": "7",
"7": "1",
"8": "6",
"9": "6",
"10": "6",
"11": "6",
"12": "6",
"13": "6",
"14": "0"
},
"nextPlayer": 0,
"gameOver": false
}
DELETE /games/{gameId}
Example
curl \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-X DELETE http://127.0.0.1:8080/games/34490f2d-ddfc-44f0-9959-d5133d13b65a
There are 2 spring profiles prod
(default) and dev
.
The main difference is logging configuration:
prod
outputs in json format and all levels toinfo
.dev
outputs in plain text andcom.adorogush.backbasetask
level isdebug
.
Key | Default value | Description |
---|---|---|
numberOfPits | 6 | Number of pits per each player. |
numberOfStones | 6 | Number of stones in each pit. |
This project follows Google Java Style Guide.