Due to the instructions, I have to implement a method -- create(). The description tells me that I should allow user to insert a new record or reuse a deleted one. However, this method must throw a DuplicateKeyException which is not specified in the description.
public int create(String data) throws DuplicateKeyException;
I read the data file and found that the data record does not have primary key field (I have to use the index of the record location as primary key to uniquely identify a record). From my understanding, I think only when a new record and an existing record have identical contents in all the fields, a DuplicateKeyException will be thrown out.
However, from the name of the Exception, it implies that the Exception should be thrown when a new record has a key duplicating the key of an existing record. Again, the problem is: there is not nature primary key, there cannot be any primary key violence. Am I right?