You are on page 1of 3

P1:

A1)
Context: Order
Inv: value >= 0

A2)
Context: Order
Inv: OrderComponents -> isEmpty() implies value = 0

A3)
Context: Order
Inv: value = OrderComponents -> collect(price) -> sum()

A4)
Context: Component
Inv: Component.allInstance() -> forAll(c1, c2) c1<>c2 -> c1.ComponentCode <> c2.ComponentCode

B)
Context: Order :: reducePrice(discount: Integer)
Pre: discount > 0

C1)
Context: Order :: cancel()
Post: confirmation = false

C2)
Context: Order:: applySale(discount: Double)
Post: value = value@pre + value@pre*discount

C3)
Context: Client:: aproveLoan(): Boolean
Post: result = (income.size() = 12 and income.forAll(sum > 2000))



P2:
a)
Context: Loan
Inv: hasWarrantor(x) = true -> customer.associate(x) = true

b)
Context: Loan
Inv: security = house > ownsHouse() = true;

c)
Context: Loan
Inv: security = house -> taxValue(house) >= 0.2 * taxValue(loan)



P3:
Context: Customer:: getLoan(): Boolean
Post: result = (income.size() = 12 and income.forAll(salary > 1000))


P4:
a)
Context: Credit
Transaction.creditCard(startDate, endDate)

b)
Context: Institution
amount.transaction(institution)

c)
Context: Customer
Count.cardAccount(customer)

d)
Context: Customer
Sum(amount.account(customer))

You might also like