• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

[B&S] some questions about "Required Interface"

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, I got some questions about the required interface

first, in the interface sun gives us the read method it says:


// Reads a record from the file. Returns an array where each
// element is a record value.
public String [] read(int recNo) throws RecordNotFoundException;



As I understand, it returns ONE record each time and the string array should carry the field values for this record. like array[0] stores the first field's value. Here "a record value" should be a field value. Is it right?

another question, what's the value of recNo? I can't find it from the database schema. Is it just a index of the record or other id? Is it in the database or just used for the program(record index)?

third question, when I use the "Data.java" to implement the interface, Can I use another class to wrap "Data.java"?


thanks in advance!!!
[ June 26, 2006: Message edited by: Nova Chen ]
 
hangman
Posts: 220
Angular Framework Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

As I understand, it returns ONE record each time and the string array should carry the field values for this record. like array[0] stores the first field's value. Here "a record value" should be a field value. Is it right?

Yes, that is the way I interpreted it.

public String [] read(int recNo) throws RecordNotFoundException;

Are you sure? In my project it was:
public String [] readRecord(long recNo) throws RecordNotFoundException; I am not sure why you get to use an "int" and I had to use a "long." No fair. ...But this is basically the unique, "nth" record in the datafile.

when I use the "Data.java" to implement the interface, Can I use another class to wrap "Data.java"?

Yes, as a matter of fact, I would find it difficult to do it any other way..

I hope this helps.
 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used the Adaptor pattern instead of wrapping to make it an object oriented data layer package. I think Sun will use the Data.java to mark your assignment so becareful. Better to be safe than sorry.

When you say wrapping I assume you mean subclassing it then you can use the interface like DB db = new SubDataClass();
 
Jimmy Chen
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Bob and Anna very much!

Bob, I can't find any long parameters in the interface of my assignment

Anna, I just want to use the adaptor as in Andrew's book (that's what I saying wrap).
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are several different versions of the assignment with small differences like different datatypes and method signatures.
reply
    Bookmark Topic Watch Topic
  • New Topic