-
Introduction
-
‘Fibonacci Numbers Game’ or ‘Numbers Game’ is a multi-player turn-base game, in each turn a player selects 3 numbers and these numbers assigned to that player, so other players can’t select these numbers again.
-
Player score is calculated based on count of Fibonacci numbers assigned to that player. For example if ‘Player1’ started the game by selected {3, 4, 5} then his score will be 2 as (3 and 5 are Fibonacci numbers), then if ‘Player2’ selected {5, 6, 8} then ‘player2’ score will be 1 as (5 is already selected by ‘Player1’ and 8 is Fibonacci) and so on.
-
-
Task
- Your company assigned to you the task of implementing REST API gaming engine server for ‘Numbers Game’ using Java, Spring-boot technology and store running games related data on MySQL database, taking in consideration that restarting the gaming engine server should not impact running games statuses.
-
Requirements
- Your source code must include Java Docs and Unit Test cases for each implemented class, and preferred integration testing.
-
REST API Specification
-
Create a Game
- HTTP Verb: POST
- URL: /api/new-game
- Request Body:
{"players": ["player1", "player2", "player3"]}
- Response:
{"game-code":<number>, "player-codes": [{"name":"player1", "code":<number>}, {"name":"player1", "code":<number>}, {"name":"player1", "code":<number>}]
-
End a Game
- HTTP Verb: POST
- URL: /api/{game-code}/end
- Request Body: Empty
- Response: Empty
-
Game Score
- HTTP Verb: GET
- URL: /api/{game-code}/score
- Request Body: Empty
- Response:
{"scores": {"player1": <number>, "player2": <number>, "player3": <number>}}
-
Get On-Turn Player
- HTTP Verb: GET
- URL: /api/{game-code}/turn
- Request Body: Empty
- Response:
{"next": "player1"}
-
Play a Move
- HTTP Verb: POST
- URL: /api/{game-code}/{player-code}/play
- Request Body:
{"Numbers": [3, 4, 5]}
- Response:
{"player-score": <number>}
-
-
Error Handling
- In case of request data doesn’t meet the required game specification, server should return HTTP
Code 400 and JSON exception payload
{ “error”:”<readable text massage describe the error>”}
- In other server related errors, server should return HTTP Code 500 and JSON exception payload
{ “error”:”<readable text massage describe the error>”}
- In case of request data doesn’t meet the required game specification, server should return HTTP
Code 400 and JSON exception payload
-
Notifications
You must be signed in to change notification settings - Fork 0
mostafaism1/fibonacci-numbers-game
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
An implementation of the Fibonacci Numbers game
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published