UML&OCL Modeling Languages


Exercises

Subject 1

Suppose you have a class Order with the following attributes:

The OrderItem class has the following attributes:

Questions

  1. Represent the UML class diagram.
  2. Write OCL expressions that satisfy the following requirements::

a. An operation that calculates the total quantity of items in an order.
b. A constraint that ensures that the total amount of an order is greater than 0.
c. A query that returns the most expensive product in an order.
d. A constraint that ensures that the order date is not in the future.
e. A query that returns the total amount of an order including tax.
NB. Note that TaxRate is a separate class with a static operation getRate(customer: Customer) : Decimal that returns the tax rate for a given customer.


9 - 9