Hi all, in URLyBird I implemented my delete() method by updating the delete flag to 1. The delete flag in my data file is 1 byte (using raf.writeByte(1)). Now for create() method, it throws DuplicateKeyException (public int create(
String[] data) throws DuplicateKeyException). I implemented mine like this:
1) find total number of records
2) loop to check if delete flag=1
3) if yes assign loop var as return val and break loop
4) update delete flag to 0 and write data
When to throw DuplicateKeyException? Currently in step 3 above, I also check the first field, if it is the same as the input's first field, I throw DKE. Does this look right?
I tested my methods like this. say I use record 5:
read(5)
delete(5)
newRecNum = create(data)) // got record number 5 correct
read(newRecNum) // same as read(5)
delete(newRecNum)
create(data) // throw DKE?