• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

NX: URLyBird 1.3.2. Question about the process of booking.

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,
Again, I am bothering you with some naive questions.
I am thinking about the process of booking and maybe returning(creating?) a room.
The following is the requirements.
---------------------------------------------
The User Interface
The user interface for this assignment must satisfy the following criteria:
It must be composed exclusively with components from the Java Foundation Classes (Swing components).
It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user.
It must present search results in a JTable.
It must allow the user to book a selected record, updating the database file accordingly.
Server
Required Interface
Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface:
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;
}
(Sorry, it's too long)
--------------------------------------------------------------------
I think the booking process should be:
1. Lock the record (using method of public void lock(int recNo)).
2. Check the record is deleted or not. If not, go to 3. If deleted, tell user it is booked by another client, and then go to 5.
3. Update the record information, e.g. fill in the customer's ID. (using method of public void update(int recNo, String [] data)).
4. Delete the record, i.e. make the mark the record as deleted, and should not be showed in other clients' GUI in the future (using the method of public void delete(int recNo)).
5. unlock the record (using the method of public void unlock(int recNo)).
My first question is, am I right?
My second question is, since the requirment only say allow the user book a selected record, it doesn't say MUST allow user to return it, need I implement the Return function? And if I want to do the return function, I think the client can do a return only in the same session in which the Booking is made. Since if the user quit the client gui, and then start it again to return a room he just booked, he can find the record in the search result(the search I am going to do, will not show the deleted records), and it is difficult for the system to judge if he is the one who booked the room. So what I can do is to write this limitation in the docment. Am I right?
My third question is, in order to implement the return function, there should be a hashmap or some other data structure to store the information about the room and the its related client which booked the room. So together there should be 2 such globle data structure, one is for the lock/unlock, another one is for the book/return. Am I right?
Oops, hope you are not tired of reading my questions!
Thanks a million!!!
Joe
 
Joe J. Wang
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am very sorry there is a typo (an important one) in my first post!
------------------------------------------------------------------------
My second question is, since the requirment only say allow the user book a selected record, it doesn't say MUST allow user to return it, need I implement the Return function? And if I want to do the return function, I think the client can do a return only in the same session in which the Booking is made. Since if the user quit the client gui, and then start it again to return a room he just booked, he CAN'T find the record in the search result(the search I am going to do, will not show the deleted records), and it is difficult for the system to judge if he is the one who booked the room. So what I can do is to write this limitation in the docment. Am I right?
-------------------------------------------------------------------------
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Joe,
I don't think you needed to post as much of the instructions as you did. When you do need to post code (as in the interface, not the instructions), could you please post them inside UBB [code ] blocks? That will make the code easier to read, and makes it easier to see where the code ends and your questions begin.

3. Update the record information, e.g. fill in the customer's ID. (using method of public void update(int recNo, String [] data)).
4. Delete the record, i.e. make the mark the record as deleted, and should not be showed in other clients' GUI in the future (using the method of public void delete(int recNo)).


I would question why you are updating the customer's ID and deleting the record. I think you only need to do the update. The fact that a record has a customer ID will imply that it is no longer available for anyone else.

My second question is, since the requirment only say allow the user book a selected record, it doesn't say MUST allow user to return it, need I implement the Return function?


I don't think you need to return anything - in fact the update() method declares the return is void (nothing to return). It would only be if the update failed, that you might throw an exception. If you do not get an exception, the update must have worked.

the user [...] CAN'T find the [modified] record in the search result [...] So what I can do is to write this limitation in the docment. Am I right?


Yes, I think you should document that decision.
Regards, Andrew
 
Joe J. Wang
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Andrew,
Thank you for the reply!
I see your points. But I still have a question, if only "update" is enough, where should I use delete/create methods? Do I need to provide the user interface to let the user delete/create records?
Thanks a lot!
Joe
 
Andrew Monkhouse
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Joe
You don't need to use the create or delete methods. They are not required in your client application.
However you have to implement the create and delete methods in your Data class, so that Sun can use them (if they want to) when they test your implementation.
Or if you prefer to think in business terms, your client application does not have create/delete capability, but UrlyBird have a separate application (written by someone else) which can create and delete records.
Regards, Andrew
 
Straws are for suckers. Now suck on this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic