Hi Jofer,
1.if don't use the LockManager,can I directness use the Lock/Unlock mechanism in the Data file?
Trying to grab someone else's code and use it could result in:
the code not fiting your requirementsyou being unable to explain some aspect of someone else's code in your exam and you failing the exam! If one of the questions in the exam is "Why did you decide to use or not use a LockManager?" how are you going to answer it?
You may be able to use S. Ganapathy's code inside your Data class, but that depends on whether your Data class is itself a Singleton, a Multiton, or has no restrictions on number of instances.
It also depends on whether
your lock methods return cookies or not!
Once you have worked out how you want your design to work, you can then look at what code you need to implement.
2.if use the LockManager,in the Data lockRecord(long recNo) method invocation:
is right?
Does your unlock() method require you to throw RecordNotFoundException?
How is your lock() method going to throw it? You do not do any validation on the record number - this could result in a failure.
3.this is a basic question,I don't know how to implement it:
in lockRecord(long recNo) method,how to get the recNo?
no fields(name,location,specialties,size,rate,owner) to storage it in the DB.
Perhaps
this thread may answer your question.
4.the lockRecord(long recNo) method throws the RecordNotFoundException Exception,but this method don't read and write message to the db file,how to occur this Exception?
Check your instructions - they tell you the circumstances in which you must throw that exception.
5.this question about the delete function,the db has 28 records,if deleted the sixth record,does the seventh record move along?
No it should not.
If a client is about to modify record number 7, and you move record 7 as a result of a deletion, which record will the client modify?
It is much easier to just leave a logical blank space in the datafile, which may get reused later.
Regards, Andrew