Class TestUser

  • All Implemented Interfaces:
    Serializable

    public class TestUser
    extends User
    A TestUser extends an User given him or her the following properties:
    • Index in the DataModel array which stores test users.
    • Array of items rated in test by the user.

    It is not recommended that developers generate new instances of this class since this is a memory-structural class.

    See Also:
    Serialized Form
    • Field Detail

      • testUserIndex

        protected int testUserIndex
        Index in the DataModel array which stores test users
      • minTest

        protected double minTest
        Minimum test rating value
      • maxTest

        protected double maxTest
        Maximum test rating value
      • averageTest

        protected double averageTest
        Average test rating
      • testItemsRatings

        protected SortedRatingList testItemsRatings
        TestItems rated by the user
    • Constructor Detail

      • TestUser

        public TestUser​(String id,
                        int userIndex,
                        int testUserIndex)
        Creates a new instance of a test user. This constructor should not be used by developers.
        Parameters:
        id - User unique identifier
        userIndex - Index in the DataModel array which stores users
        testUserIndex - Index in the DataModel array which stores test users
    • Method Detail

      • getTestUserIndex

        public int getTestUserIndex()
        Returns the test user index inside the DataModel
        Returns:
        testUserIndex inside the DataModel
      • getTestItemAt

        public int getTestItemAt​(int pos)
        Returns the index of the TestItem rated by the TestUser at the given position.
        Parameters:
        pos - Position
        Returns:
        Index of the test item in the TestItems' array of the DataModel
      • getTestRatingAt

        public double getTestRatingAt​(int pos)
        Returns the test rating of the user to the test item at the pos position
        Parameters:
        pos - Position
        Returns:
        Test rating at indicated position
      • findTestItem

        public int findTestItem​(int testItemIndex)
        Finds position of a user's test rating given the index of the TestItem in the DataModel.
        Parameters:
        testItemIndex - Test item index
        Returns:
        TestItem position if the test item has been rated by the test user or -1 if do not
      • getNumberOfTestRatings

        public int getNumberOfTestRatings()
        Gets the number of test items rated by the user.
        Returns:
        Number of test ratings
      • addTestRating

        public void addTestRating​(int testItemIndex,
                                  double rating)
        Adds a new test rating of the test user to an test item. You cannot overwrite an existing rating, otherwise this method will throws an IllegalArgumentException. It is not recommended to use this method, use DataModel.addTestRating(...) instead.
        Parameters:
        testItemIndex - Test item index which identifies a test item in the DataModel
        rating - Rating value
      • getMinTestRating

        public double getMinTestRating()
        Gets the minimum test rating of the user
        Returns:
        Minimum test rating
      • getMaxTestRating

        public double getMaxTestRating()
        Gets the maximum test rating of the user
        Returns:
        Maximum test rating
      • getTestRatingAverage

        public double getTestRatingAverage()
        Gets the average value of test ratings
        Returns:
        Test rating average