5. week

Specification of services for GameStudio

Description

The services should support the following functionality:

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

Warning

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

Comment

This specification is general regarding database data types, so when adding columns to a table, you need to choose data types that are specifically supported by the PostgreSQL database system. Use your knowledge from the subject Database Systems.

1. Service SCORE:

The list of columns for the 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