This class models the central resource. We assume there is only one
central resource in the system, though many tills can be connected to
this. The central resource holds the accounts, ids of illegal cards, and connections to a clock and a letterbox.
The following three operations provide the functionality requested in the
requirements specification of the system. The operations first check that
the requested functionality is allowed andthen hand the actual processing
over to each account. Note that the checks are necessary even though the
till may have performed them as well. For example, a card may have been
reported stolen or illegal in another way while it is being used at a till.
\begin{vdm_al}
pure public GetBalance : Account`AccountId ==> [nat]
GetBalance(accountId) == if accountId insetdom accounts then
accounts(accountId).GetBalance() else returnnil;
public Withdrawal : Account`AccountId * Card`CardId * nat ==> bool
Withdrawal(accountId,cardId,amount) == if IsLegalCard(accountId,cardId) then
accounts(accountId).Withdrawal(cardId,amount,clock.GetDate()) else returnfalse;
public PostStatement : Account`AccountId * Card`CardId ==> bool
PostStatement(accountId,cardId) == if IsLegalCard(accountId,cardId) then
(letterbox.PostStatement
(accounts(accountId).MakeStatement(cardId,clock.GetDate())); returntrue) else returnfalse;
\end{vdm_al}
Next some operations follow to check whether cards are legal and
administrate number of tries stored for each card.
\begin{vdm_al}
pure public IsLegalCard : Account`AccountId * Card`CardId ==> bool
IsLegalCard(accountId,cardId) == return
cardId notinset illegalCards and
accountId insetdom accounts and
cardId inset accounts(accountId).GetCardIds();
pure public NumberOfTriesExceeded : Card`CardId ==> bool
NumberOfTriesExceeded(cardId) == return numberOfTries(cardId) >= maxNumberOfTries;
public AddIllegalCard : Card`CardId ==> ()
AddIllegalCard(cId) ==
illegalCards := illegalCards union {cId};
end CentralResource
\end{vdm_al}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.17Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.