| Author |
NX: URLy Bird 1.3.1 Exception Declaration
|
Bharat Ruparel
Ranch Hand
Joined: Jul 30, 2003
Posts: 493
|
|
I am having trouble interpreting Sun' directions for the DBMain.java interface. It is defined as follows: package suncertify.db; public interface DBMain { // Reads a record from the file. Returns an array where each // element is a record value. public String [] read(int recNo) throws RecordNotFoundException; // Modifies the fields of a record. The new value for field n // appears in data[n]. public void update(int recNo, String [] data) throws RecordNotFoundException; // Deletes a record, making the record number and associated disk // storage available for reuse. public void delete(int recNo) throws RecordNotFoundException; // Returns an array of record numbers that match the specified // criteria. Field n in the database file is described by // criteria[n]. A null value in criteria[n] matches any field // value. A non-null value in criteria[n] matches any field // value that begins with criteria[n]. (For example, "Fred" // matches "Fred" or "Freddy".) public int [] find(String [] criteria) throws RecordNotFoundException; // Creates a new record in the database (possibly reusing a // deleted entry). Inserts the given data, and returns the record // number of the new record. public int create(String [] data) throws DuplicateKeyException; // Locks a record so that it can only be updated or deleted by this client. // If the specified record is already locked, the current thread gives up // the CPU and consumes no CPU cycles until the record is unlocked. public void lock(int recNo) throws RecordNotFoundException; // Releases the lock on a record. public void unlock(int recNo) throws RecordNotFoundException; // Determines if a record is currenly locked. Returns true if the // record is locked, false otherwise. public boolean isLocked(int recNo) throws RecordNotFoundException; } The instructions further state:
Any unimplemented exceptions in this interface must all be created as member classes of the suncertify.db package. Each must have a zero argument constructor and a second constructor that takes a String that serves as the exception's description.
My question is: Since RecordNotFoundException and DuplicateKeyException are to be defined by me (the programmer) and they should go in the same package, i.e., suncertify.db, will I not have to at least declare the import statements in the above interface declaration? I will show this below: package surcertify.db; import suncertify.db.RecordNotFoundException; import suncertify.db.DuplicateKeyException; public interface DBMain { // Reads a record from the file. Returns an array where each // element is a record value. ..... } But then the instructions say that I shouldn't be modifying the given interface at all? Will this qualify as automatic failure? Help!!!
|
SCJP,SCJD,SCWCD,SCBCD,SCDJWS,SCEA
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
|
No, you don't have to import classes from the same package. Try omitting the imports - should work fine.
|
"I'm not back." - Bill Harding, Twister
|
 |
Leo Tien
Ranch Hand
Joined: Sep 10, 2002
Posts: 156
|
|
Hi, Bharat
But then the instructions say that I shouldn't be modifying the given interface at all? Will this qualify as automatic failure?
It is true?? But I cann't find this statement in my assignment, my assignment version is 1.3.1 too? Whether i miss, but i'v look it three times carefully.
|
 |
Bharat Ruparel
Ranch Hand
Joined: Jul 30, 2003
Posts: 493
|
|
Hello Jim, You are right, I was programming badly (and thinking worse!). The same package classes don't have to be imported. Hello Leo, You are right as well. I have looked through my instructions and nowhere there-in they specifically forbid not allowing us to import the import the classes that you need to use. As I mentioned above to Jim, it was my error causing me to conclude incorrectly that I needed to import the classes that I needed to. I guess the discussions on this forum have put the "fear of God (or Sun)" in me. I feel uneasy when I am touching either DBMain.java or Data.java. Sorry about the unnecessary alarm. Jim, thanks for your help. Regards. Bharat
|
 |
 |
|
|
subject: NX: URLy Bird 1.3.1 Exception Declaration
|
|
|