I am supposed to create a public StudentDatabase() which should create an empty database without using an java api class or method. There is supposed to be a method: public boolean add(String macid, int exam1, int exam2) which adds a record to the database. If the student whose MacID is macid is already in the database, this method updates his/her grades with exam1 and exam 2 and returns false; otherwise, it creates macid, exam1 and exam 2 as a new record in the database and returns true. I have gotten this far:
public class StudentDatabase
{
public StudentDatabase()
{
Map<String, Set<int>> = new HashMap<String,List<int>>();
}
public boolean add(String macid, int exam1, int exam2)
{
remove(0);
return false;
}
public int getExam1(String macid)
{
if (sdb.macid("ID_") = macid);
else
return -1;
}
public int getExam2(String macid)
{
return -1;
}
public boolean remove(String macid)
{
if (StudentDatabase.macid == macid[]) {
for (int j = i; j < (size - 1); j++)
{
ARRAY[j] = ARRAY[j + 1]; //shift elements left
}
return true;
}
return false;
}
public int query(int exam1Low, int exam1High, int exam2Low, int exam2High)
{
return 0;
}
}
I dont understand how I can create a database using Map. Any help would be greatly appreciated. Thank you