rendered paste bodyAufgabe 2
a) context Mannschaft
inv: not spiel.oclIsTypeOf(Paarung)
b) *context Gruppe
inv: team->size()=4
*
c) context Paarung
def: gewinner()
context Viertelfinale
def: alleMannschaften() : Set(Mannschaft) =
gewinner().spiel->select(oclIsTypeOf(Halbfinale)).gewinner().spiel->select(oclIsTypeOf(Finale)).team.spiel->select(oclIsTypeOf(Halbfinale)).team.spiel->select(oclIsTypeOf(Viertelfinale)).team->asSet()
d) context Paarung
def: toreA : Integer
def: toreB : Integer
def: ergebnis() : String =
toreA.concat(' : ').concat(toreB)
e) context Mannschaft
def: punkte : Integer
def: geschosseneTore : Integer
def: bekommeneTore : Integer
derive: torverhaeltnis = geschosseneTore - bekommeneTore
context Vorrundenspiel::spiel()
body: team->first().geschosseneTore += toreA
team->first().bekommeneTore += toreB
team->last().geschosseneTore += toreB
team->last().bekommeneTore += toreA
if toreA>toreB
then team->first().punkte += 3
endif
if toreA<toreB
then team->last().punkte += 3
endif
if toreA=toreB
then team->first().punkte += 1
team->last().punkte += 1
endif
context Gruppe::erster() : Mannschaft
body: team->select(punkte=team->sortedBy(punkte)->first().punkte)->
sortedBy(torverhaeltis)->first()
context Gruppe::zweiter() : Mannschaft
body: team->exclude(self.erster())->select(punkte=team->exclude(self.erster())->sortedBy(punkte)->first().punkte)->sortedBy(torverhaeltis)->first()
Aufgabe 4:
a)
wahr, falsch, falsch
wahr, falsch
b) context User
inv: self.konto.bank=self.bank
c)context Tagesgeldkonto
inv: user->oclIsTypeOf(TagesgeldKontoUser)
context Girokonto
inv: user->oclIsTypeOf(GiroUser)
d)bag
set