GeeCON Prague 2014*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes 8 bit coding problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "8 bit coding problem" Watch "8 bit coding problem" New topic
Author

8 bit coding problem

Pankaja Bansal
Greenhorn

Joined: Feb 16, 2006
Posts: 19
Hi everybody

I am working on the URLyBird assignment and I've designed my project but when I tried to parse the datafile provided to me, there seems to be something wrong. I am using DataInputStream to read bytes and then I convert these bytes to Strings. I could read schema details in this fashion but when I try to read the data part, it seems to have start fine but with every next read statement, it reads an extra byte and so the last row contains a most of the data from other fields. There seem to be something wrong either with the data file or am I doing something wrong while parsing.

The specs says I must use 8 bit US-ASCII and I am using that in the manner below

String name = new String (bytes, "US-ASCII") ;

Anything else I am supposed to do..Please help me out as I am stuck here...

Cheers
PB
Aruneesh Salhotra
Ranch Hand

Joined: May 12, 2004
Posts: 167
U got a datafile. Is it part of the assignment. I think I better download my assignment again. I think I got the question only, and defined/created the file myself.

Please confirm.
Pankaja Bansal
Greenhorn

Joined: Feb 16, 2006
Posts: 19
I found the mistake I was making while parsing the file. To read whether the record is deleted or not, I was using readBoolean() which was creating all the problems. It was actually a short value and now I can parse my file correctly.

Now the problem I am facing is in deciding the fields that need to be part of the primary key. Actually I am confused whether I should include the Date as part of the primary key or not. IF the date available is "THE date on which the room can be booked" and not "the STARTING date from when the room can be booked", then I guess I should include it as a part of primary key since the room can be available for 5 consecutive nights although booking would in such a case be possible just for the first 3 nights (48 hours constraint).

If it is the latter case, and the date is the starting date then probably I can leave the date from the primary key. Need your suggestions and expert guidance. Please let me know what you feel.

Regards
PB
Aruneesh Salhotra
Ranch Hand

Joined: May 12, 2004
Posts: 167
There is no information provided for the primary key. As far as I am concerned, I would use hotel/location as the primary key.

Whatever key you use, you should mention in the readme/design file.
Eiji Seki
Ranch Hand

Joined: Feb 15, 2006
Posts: 88
Originally posted by Aruneesh Salhotra:
U got a datafile. Is it part of the assignment. I think I better download my assignment again. I think I got the question only, and defined/created the file myself.

Please confirm.


You may or may not get a data file depending on the version of your assignment. Even if it seems that everyone is working on the same URLyBird, they are different versions with differences between them.


SCJD URLyBird (WIP)<br />SCJP 1.5
Eiji Seki
Ranch Hand

Joined: Feb 15, 2006
Posts: 88
Originally posted by Aruneesh Salhotra:
There is no information provided for the primary key. As far as I am concerned, I would use hotel/location as the primary key.

Whatever key you use, you should mention in the readme/design file.


Yes, there is no information about primary key at all. Not in the spec nor in the schema, so I don't think we can decide on one without limiting the data format expansion.

Notice that hotel/location is not a primary key, since there are many rooms in the same hotel. I thought about it because of other thread and I don't think even the entire record is unique, so I don't agree even on using the whole record as PK.

My conclusion is based on my spec, not sure if the same applies to everyone.

(argh, my english is rusty)
[ February 17, 2006: Message edited by: Eiji Seki ]
Kevin Conaway
Ranch Hand

Joined: Jan 27, 2006
Posts: 57
Pankaja,

Regarding the 8-bit coding, see this dicussion as it provides a good answer to your question.

Kevin
Pankaja Bansal
Greenhorn

Joined: Feb 16, 2006
Posts: 19
I agree with you all that primary key is not defined in the spec,but the interface contains the add method which throws a DuplicateKeyException so I guess there should be a primary key defined.

Thinking of the normal scenario, a hotel may have many rooms and the same room can be available for booking on more than one night, I think, I would make all but owner fields as the primary key. Although there may be two exactly similar rooms in the same hotel and available on the same night as well, but in the current data scope such a situation ccannot be handled so, I am just assuming that each hotel has all different rooms. Please let me know if I am making any false assumptions.
Aruneesh Salhotra
Ranch Hand

Joined: May 12, 2004
Posts: 167
If this was an actual hotel booking applications, things would be outlined very differently.
Instead of DB file, it would be a RDBMS. It is only a testing exercise.
Assuming a hotel has only one room is a decent assumption. But whatever one decides need to be mentioned in the design and assumption documentation.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: 8 bit coding problem