JADE is an advanced software platform that has an integrated software development environment, a language, an object manager, and a high performance database.


Why is this Method Needed?

In the application you will build, a borrower randomly chooses books to check out and check in.

For check outs, the book comes from the library's allBooks collection.

For check ins, the book comes from the borrower's myBooks collection.

So a method to randomly choose a book from any BookDictionary collection will be very useful.

Instructions

  1. In the Class Browser, select the BookDictionary class.
  2. Select the Methods | New JADE Method... menu. The JADE Method Definition dialog is displayed.
  3. Enter chooseBook and click the OK button. A skeleton method is created ready for you to code.
  4. Copy and compile the code on the right.

chooseBook() : Book;

vars
    i : Integer;
    iter : Iterator;
    bk : Book;
begin
    i := app.random(size - 1) + 1;
    iter := createIterator;
    iter.startAtIndex(i);
    iter.next(bk);
    return bk;       // return the randomly chosen book
epilog
    delete iter;
end;

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 Contents
 

For maximum reliability, security and performance of your JADE solution, JADE Care24 is our fully comprehensive systems management offering.