Hi,
I'm getting this weird error where it can't access the set method (compilation error as well) but this makes no sense, look at the code:
public boolean set(K key, V val)
{
// Find the desired value
int index = this.hash(key);
Bucket<K, V> bucket = this.table[index];
KeyValuePair<K, V> curr = bucket.head;
// Search iteratively for the target element within the bucket
while(curr != null)
{
// If the key is equal to the one we want to set
if(curr.getKey().equals(key))
{
curr.setVal(val);
return true;
}
curr = curr.getNext();
}
throw new NoSuchElementException("Key does not exist within the HashMap!");
}```
And the function trying to access this method:
```java
private void updateAverageRating(int movieid, float rating)
{
// Retrieve the old average, if it is a null no average was set yet so simply assign 0
RatingAverage avg = averageMovieRatings.get(movieid);
float oldAverage = avg.getAverage();
float newAverage = oldAverage + (rating / avg.getMovieCount());
averageMovieRatings.set(movieid, newAverage);
}```
set is public and defined within averageMovieRatings which is an instance of HashMap which contains the method. Why on earth is it not finding set?