my dog learned polymorphism
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes display issue 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 "display issue " Watch "display issue " New topic

display issue

Alexandra Zhang

Joined: Jun 08, 2007
Posts: 16
Hey, for who is still here, I need help.

I got a URLBird assignment. And I finished all the individual function and requirement, but after integrated parts together, many things went wrong. One thing I really tried, but have no clue how to fix it. My GUI displays customer id. But after booking the value can not correctly displayed, it shows like "©ä«". what could be wrong?

Not sure, whether I may past my code here. I used RandomAccessFile and readShort(), and writeShort().

Roel De Nijs

Joined: Jul 19, 2004
Posts: 8403

Hi Alexandra,

First of all, congratulations! You asked the 1st question after the deadline of the mandatory course requirement has elapsed.

So you display the customer id and when you update the value, it shows something unreadible. You use readShort() and writeShort() to handle the customer id? Why did you decide to use these xxxShort-methods? Because a Short has a maximum value of 32767 and your customer id has to be an 8-digit number. I would think that's causing the problem.

Good luck!
Kind regards,

SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
Anayonkar Shivalkar

Joined: Dec 08, 2010
Posts: 1545

Hi Alexandra,

The best way to handle this is : consider customer id as String of length 8 (just check if this is not breaking any requirements).

I internally used a record number (for locking/unlocking record) which was an 'int' (meaning my code will not support data file with more than 32767 records, and I did mention this in choices.txt), but my requirement said that owner id must be 8 digit long (but did not explicitly mention any data-type).

Just think about it : why do you want to treat customer id as 'number'? Are you doing any 'numerical' operations on it? I don't think so. All you'll be doing is - add a new record, delete a record and so on.

So, I would strongly recommend to treat customer id as String, and make very sure to add a validation at UI level that user can enter only numerical data there (and that too, max 8 characters long).

Hope this helps.

All the best!

Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
I agree. Here's the link:
subject: display issue
It's not a secret anymore!