I'm trying to call the calcHash method to get a hash index but I am getting the cannot resolve symbol error message(not recognising calcHash).I am a bit stumped.
class Student
{
String name;
String course;
int hashIndex;
public Student(String name,String course)
{
this.name =name;
this.course =course;
}
public String getName()
{
return name;
}
public String getCourse()
{
return course;
}
public int calcHash(int maxNum)
{
int hashTotal = 0;
int hashIndex = 0;
for(int i = 0; i<name.length();i++)
{
char letter = name.charAt(i);
int asciiValue = letter;
hashTotal = hashTotal + asciiValue;
hashIndex = hashTotal % maxNum;
}
return hashIndex;
}
}
class Storage
{
int maxNum = 4;
Storage StArray[] = new Storage[4];
public void add(int hashIndex,String name)
{
for(hashIndex=0;hashIndex<maxNum;hashIndex++)
StArray[hashIndex]=calcHash(maxNum);
}
}