5. week

Specification of services for GameStudio

Description

Services should support the following functionality:

  • Score - add score of the player, including the name of the player and value of score; listing top scores of players for given game.
  • Comment - add comment to the game together with name of the player; listing comments for given game.
  • Rating - add rating for the game together with player's name; showing the rating entered by the player and average rating for the game.

Warning

When implementing the services, follow the specification of provided interfaces from the archive serviceSpecs.zip, which is also described below.

Comment

This specification is general regarding the data types in the database, so when you add columns into the table, you need to choose data types which are supported specifically by the database system Postgresql. Use your knowledge from the subject Database systems.

1. Service SCORE:

The list of columns for database table SCORE:

player : TEXT
game : TEXT
points : INTEGER
playedOn: DATE

The interface ScoreService.java contains the following methods:

  • void addScore(Score score) throws ScoreException;
  • List<Score> getTopScores(String game) throws ScoreException;
  • void reset() throws ScoreException;

2. Service COMMENT:

The list of columns for database table COMMENT:

player : TEXT
game : TEXT
comment : TEXT
commentedOn: DATE

The interface CommentService.java contains the following methods:

  • void addComment(Comment comment) throws CommentException;
  • List<Comment> getComments(String game) throws CommentException;
  • void reset() throws CommentException;

3. Service RATING:

The list of columns for database table RATING:

player : TEXT
game : TEXT
rating : INTEGER
ratedOn: DATE

The interface RatingService.java contains the following methods:

  • void setRating(Rating rating) throws RatingException;
  • int getAverageRating(String game) throws RatingException;
  • int getRating(String game, String player) throws RatingException;
  • void reset() throws RatingException;

Comment

The Rating service should work similarly to ratings by stars, e.g. as in application stores. In a console user interface, the rating will be represented as a number.

The method for adding a rating will work a little differently compared to other services: it will not add new rating, but set it (therefore it is also named set). If there is no rating in the database for given game belonging to given user, new entry will be added into the database. However, when such rating is already in the database, the value of rating in the existing entry should be updated.

The primary key is therefore a combination of player's name and the name of rated game.

The value of rating should be in the range 1-5.

Resources

  1. Interfaces of services - serviceSpecs.zip
  2. Documentation of Postgresql datatypes