Checking an implies invariant on accounts

A banking model has the following OCL invariant on the class Account, where type is a String and balance is a Real:


Plain text
context Account
inv SavingsNotOverdrawn:
    self.type = 'savings' implies self.balance >= 0


For each account in the snapshot below, type true if the invariant holds for that account and false if it is violated.

AccountTypeBalanceInvariant holds
A1savings120
A2savings-40
A3chequing-40
A4savings0
A5chequing300
A6savings-5

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Object Constraint Language (OCL) Questions: