This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can only return type Iterable from DataStore

 
Johnny Donovan
Greenhorn
Posts: 6
Firefox Browser Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

Im trying to help a friend out. He received a project from college an we struggling to understand the one problem constraint.

Its says - The provided DataStore is not optimally organized.
• It can only return iterables (See java.lang.Iterable<T>) of each object type.

We really dont understand what they mean, as far as i know a DataStore may only return type ResultSet?

Thanks in advance
 
Jan Cumps
Bartender
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jonathan, Welcome to the Ranch!

Can you give us the exact message you are getting?
 
Johnny Donovan
Greenhorn
Posts: 6
Firefox Browser Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jan, thanks for the welcome

This isnt an error message or anything. In the description of what he will have to do for the project it has a few problem constraints.
The one constraint says that the DataStore he has to use can only return Iterables of each object .

I have pasted a short snippet from his project desciption below:

Hint 1:
When a Card Processor (the class you are writing) is created it is linked to a DataStore. You can access this data store by calling the method getDataStore().
Initially a DataStore it is empty. You can add Customer, Account and Card objects to it one-by-one to do some testing.
When your Card processor is tested by running the Transaction Processor the DataStore will be filled with random data before your Card Processor is initialized.

Hint 2:
The provided DataStore is not optimally organized.
• It can only return iterables (See java.lang.Iterable<T>) of each object type.
• Customer objects do not have any reference to the cards/accounts that are linked to them.

Designing new internal data structures may make queries against the data easier.
See ACardProcessor.init().

Hint 3:
The relationship between the objects in the problem domain is shown below. Note that a Card is uniquely identified by a combination of the card number and expiry date and an account by the account number and account type.


 
Matthew Brown
Bartender
Posts: 4567
8
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Johnothan Routledge wrote:We really dont understand what they mean, as far as i know a DataStore may only return type ResultSet?

If the DataStore is a provided class, then presumably it can return whatever the writer intended it to return. Why would it be restricted to only returning ResultSets?

It sounds to me like what you need to do is to extract the data from the DataStore (using the interface provided) and store it in your own data structure designed to make whatever searches you have to make easy. Exactly what these data structures are depends on what the expected queries are. For instance, if you needed to search for customers by name, then storing them in a map with the names as a key would make searching easy.
 
Johnny Donovan
Greenhorn
Posts: 6
Firefox Browser Java Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Brown wrote:
Johnothan Routledge wrote:We really dont understand what they mean, as far as i know a DataStore may only return type ResultSet?

If the DataStore is a provided class, then presumably it can return whatever the writer intended it to return. Why would it be restricted to only returning ResultSets?

It sounds to me like what you need to do is to extract the data from the DataStore (using the interface provided) and store it in your own data structure designed to make whatever searches you have to make easy. Exactly what these data structures are depends on what the expected queries are. For instance, if you needed to search for customers by name, then storing them in a map with the names as a key would make searching easy.


I see. We thought, when they said design a new internal data structure to make queries easier, that it meant we should add a CustomerID to all the tables so that references to each table could be made.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic