Lösungsvorschlag Software Architecture FS08

Aus VISki
Wechseln zu: Navigation, Suche

1 Modularity, ADT, Designy by Contract and Concurrency (8 points)

1

b

d

f: true, since the visitor needs to know implementation details of the objects it visits

2

b: true because class invariants are 'and'-ed, hence stronger assertions can be introduced

c

2 Design by Contract (12 points)

<eiffel> class

 BANK_ACCOUNT

feature withdraw(v: INTEGER) is

 require TRUE

do end

feature balance: INTEGER

end

class STUDENT_ACCOUNT inherit BANK_ACCOUNT redefine withdraw end

feature withdraw(v: INTEGER) is require else balance >= v do

 balance := balance - v

ensure

 balance_altered: balance = balance - v

end

end

class B_A_NORMAL inherit BANK_ACCOUNT redefine withdraw end

feature withdraw(v: INTEGER) is require else balance - fee >= v do

 balance := balance -v

ensure

 balance_altered: balance = balance - v

end

feature

 fee: INTEGER

end

class B_A_BUSINESS inherit BANK_ACCOUNT redefine withdraw end

feature withdraw(v: INTEGER) is require else balance + credit >= v do

 balance := balance -v

ensure

 balance_altered: balance = balance - v

end

feature

 credit: INTEGER

end </eiffel>