Tracking repeated parcel masses

A parcel-processing model records the mass of each parcel in kilograms. Its OCL variable masses : Bag(Integer) currently has the value Bag{12, 12, 18, 25, 25, 25}. Every value is defined.


Evaluate the following expressions. Each expression starts from the original value of masses; evaluating an expression does not change it. Enter exact integers in the result table. The results are counts, rather than masses.

  • E1: masses->size()
  • E2: masses->count(25)
  • E3: masses->asSet()->size()
  • E4: masses->including(25)->count(25)
  • E5: masses->excluding(25)->size()
  • E6: masses->asSet()->including(25)->size()
ExpressionResult
E1
E2
E3
E4
E5
E6

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: