Interface PlayTime

All Known Implementing Classes:
PlayTimeProvider

public sealed interface PlayTime permits PlayTimeProvider
The PlayTime interface provides methods to manage and manipulate play time for users.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addTime(int userId)
    Increments the play time for a user with the specified user ID by one unit.
    void
    addTime(int userId, PlayTimeType type, int time)
    Adds a specified amount of play time for a user based on the given play time type.
    void
    createUser(int userId)
    Creates a user with the specified user ID in the playtime system.
    void
    deleteUser(int userId)
    Deletes a user with the specified user ID from the playtime system.
    boolean
    existsUser(int userId)
    Checks if a user with the specified user ID exists in the playtime system.
    int
    getTime(int userId)
    Retrieves the play time, in seconds, of a user identified by the specified user ID.
    void
    removeTime(int userId)
    Removes one unit of play time from the play time of the user with the specified user ID.
    void
    removeTime(int userId, PlayTimeType type, int time)
    Removes a specified amount of play time for a user with the given user ID and play time type.
    void
    resetTime(int userId)
    Resets the playtime of a user with the specified user ID to zero.
    void
    setTime(int userId, int time)
    Sets the play time for a specific user.
  • Method Details

    • existsUser

      boolean existsUser(int userId)
      Checks if a user with the specified user ID exists in the playtime system.
      Parameters:
      userId - The ID of the user to check for existence.
      Returns:
      true if the user exists, false otherwise.
    • createUser

      void createUser(int userId)
      Creates a user with the specified user ID in the playtime system. If the user already exists, no action is taken.
      Parameters:
      userId - The ID of the user to create
    • deleteUser

      void deleteUser(int userId)
      Deletes a user with the specified user ID from the playtime system.
      Parameters:
      userId - The ID of the user to delete
    • getTime

      int getTime(int userId)
      Retrieves the play time, in seconds, of a user identified by the specified user ID.
      Parameters:
      userId - The ID of the user whose play time is being retrieved.
      Returns:
      The play time of the user in seconds, or -1 if the user ID does not exist in the database.
    • setTime

      void setTime(int userId, int time)
      Sets the play time for a specific user.
      Parameters:
      userId - The ID of the user whose play time is being set.
      time - The new play time value to set, specified in seconds.
    • addTime

      void addTime(int userId)
      Increments the play time for a user with the specified user ID by one unit.
      Parameters:
      userId - The ID of the user whose play time will be incremented
    • addTime

      void addTime(int userId, PlayTimeType type, int time)
      Adds a specified amount of play time for a user based on the given play time type.
      Parameters:
      userId - The ID of the user whose play time will be increased
      type - The type of play time to be added (e.g., seconds, minutes, hours, etc.)
      time - The amount of play time to add, specified in the given play time type
    • removeTime

      void removeTime(int userId)
      Removes one unit of play time from the play time of the user with the specified user ID.
      Parameters:
      userId - The ID of the user whose play time will be decreased by one unit
    • removeTime

      void removeTime(int userId, PlayTimeType type, int time)
      Removes a specified amount of play time for a user with the given user ID and play time type.
      Parameters:
      userId - The ID of the user whose play time will be reduced
      type - The type of play time to be removed (e.g., seconds, minutes, hours)
      time - The amount of time to be removed, specified in the given play time type
    • resetTime

      void resetTime(int userId)
      Resets the playtime of a user with the specified user ID to zero.
      Parameters:
      userId - The ID of the user whose playtime is to be reset