Package es.upm.etsisi.cf4j.data
Class TestItem
- java.lang.Object
-
- es.upm.etsisi.cf4j.data.Item
-
- es.upm.etsisi.cf4j.data.TestItem
-
- All Implemented Interfaces:
Serializable
public class TestItem extends Item
A TestItem extends an Item given it the following properties:- Index in the DataModel array which stores test items.
- Array of test ratings made by the test users.
It is not recommended that developers generate new instances of this class since this is a memory-structural class.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected double
averageTest
Average test ratingprotected double
maxTest
Maximum test rating valueprotected double
minTest
Minimum test rating valueprotected int
testItemIndex
Index in the DataModel array which stores test itemsprotected SortedRatingList
testUsersRatings
Array of test users that have rated this test item
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTestRating(int testUserIndex, double rating)
Adds a new test rating of a test user to the test item.int
findTestUser(int testUserIndex)
Finds position of a rating that an test user has made to the test item given the index of the TestUser in the DataModel.double
getMaxTestRating()
Gets the maximum test rating received by the itemdouble
getMinTestRating()
Gets the minimum test rating received by the itemint
getNumberOfTestRatings()
Gets the number of test users that have rated the item.int
getTestItemIndex()
Returns the test item index inside the DataModeldouble
getTestRatingAt(int pos)
Returns the test rating of the test user to the test item at the pos positiondouble
getTestRatingAverage()
Gets the average value of test ratingsint
getTestUserAt(int pos)
Returns the index of the TestUser that have test rated the TestItem at the given position-
Methods inherited from class es.upm.etsisi.cf4j.data.Item
addRating, findUser, getDataBank, getId, getItemIndex, getMaxRating, getMinRating, getNumberOfRatings, getRatingAt, getRatingAverage, getUserAt
-
-
-
-
Field Detail
-
testItemIndex
protected int testItemIndex
Index in the DataModel array which stores test items
-
minTest
protected double minTest
Minimum test rating value
-
maxTest
protected double maxTest
Maximum test rating value
-
averageTest
protected double averageTest
Average test rating
-
testUsersRatings
protected SortedRatingList testUsersRatings
Array of test users that have rated this test item
-
-
Constructor Detail
-
TestItem
public TestItem(String id, int itemIndex, int testItemIndex)
Creates a new instance of a test item. This constructor should not be used by developers.- Parameters:
id
- Item unique identifieritemIndex
- Index in the DataModel array which stores itemstestItemIndex
- Index in the DataModel array which stores test items
-
-
Method Detail
-
getTestItemIndex
public int getTestItemIndex()
Returns the test item index inside the DataModel- Returns:
- testItemIndex inside the DataModel
-
getTestUserAt
public int getTestUserAt(int pos)
Returns the index of the TestUser that have test rated the TestItem at the given position- Parameters:
pos
- Position- Returns:
- Index of the test user in the TestUsers' array of the DataModel
-
getTestRatingAt
public double getTestRatingAt(int pos)
Returns the test rating of the test user to the test item at the pos position- Parameters:
pos
- Position- Returns:
- Test rating at indicated position
-
findTestUser
public int findTestUser(int testUserIndex)
Finds position of a rating that an test user has made to the test item given the index of the TestUser in the DataModel.- Parameters:
testUserIndex
- Test user index- Returns:
- TestUser 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 users that have rated the item.- Returns:
- Number of test ratings
-
addTestRating
public void addTestRating(int testUserIndex, double rating)
Adds a new test rating of a test user to the 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:
testUserIndex
- Test user index which identifies the specific test user in the DataModelrating
- Rating value
-
getMinTestRating
public double getMinTestRating()
Gets the minimum test rating received by the item- Returns:
- Minimum test rating
-
getMaxTestRating
public double getMaxTestRating()
Gets the maximum test rating received by the item- Returns:
- Maximum test rating
-
getTestRatingAverage
public double getTestRatingAverage()
Gets the average value of test ratings- Returns:
- Test rating average
-
-