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


checkout Method Explained

First a book is selected at random from the library's allBooks collection, using the chooseBook method.

If the book is not already out, the borrower checks it out by setting its myBorrower reference to self. Otherwise, no action is taken.

The timerEvent method, see below, calls this method.

Instructions

  1. In the Class Browser, select the Borrower class.
  2. Select the Methods | New JADE Method... menu.
  3. Enter checkout and click the OK button.
  4. Copy and compile the code on the right.

checkout();

vars
    bk : Book;
begin
    bk := LendingLibrary.firstInstance.allBooks.chooseBook;
    if bk.myBorrower = null then
        bk.myBorrower := self;
    endif;
end;

checkin Method Explained

First a book is selected at random from the borrower's myBooks collection, using the chooseBook method.

The borrower checks the book in by setting its myBorrower reference to null.

The timerEvent method, see below, calls this method.

Instructions

  1. In the Class Browser, select the Borrower class.
  2. Select the Methods | New JADE Method... menu.
  3. Enter checkin and click the OK button.
  4. Copy and compile the code on the right.

checkin();

vars
    bk : Book;
begin
    bk := myBooks.chooseBook;
    bk.myBorrower := null;
end;

timerEvent Method Explained

This method is executed when a timer signal is received.

If the borrower has no books checked out, the checkout method is called.

If the borrower has 4 books (maximum allowed) checked out, the checkin method is called.

Otherwise each method is called with a 50-50 chance.

Then the timer is restarted.

Change the timer period (currently 1000) and the maximum number of books (currently 4) if you want.

Instructions

  1. In the Class Browser, select the Borrower class.
  2. Select the Methods | New JADE Method... menu.
  3. Enter timerEvent and click the OK button.
    You are advised that you are reimplementing a superclass method. Click Yes to continue.
  4. Copy and compile the code on the right.

timerEvent(eventTag : Integer);

begin
    beginTransaction;
    if myBooks.size = 0 then checkout;
    elseif myBooks.size = 4 then checkin;
    elseif app.random(1).isOdd then checkout;
    else checkin;
    endif;
    commitTransaction;
    beginTimer(1000, Timer_OneShot, 0);
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.