Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Jorge Borrás i Duarte & Pol Garrido Melis 08 / 05 / 2022

Exàmen 4)
Context: Sistema::AltaExemplar(nomEx : String, nomEsp : String, sexeE : TipusSexe,

mínimKg : Integer, màximKg : Integer, fèrtil : Boolean)

Pre: Espècie.allInstances()->exists(esp | esp.nom = nomEsp and

esp.zona->exists(z | z.espècie.size() >=2))

Post: Exemplar.allInstances()->exists(e | e.nom = nomEx and e.sexe = sexeE and

e.oclIsNew() and e.espècie.nom = nomEsp and

if (e.espècie.nom = ‘Lleó’) then e.oclIsTypeOf(ExemplarLleó) and

e.oclIsAsType(ExemplarLleó).mínimKg = mínimKg and

e.oclIsAsType(ExemplarLleó).màximKg = màximKg and

if (e.sexe = ‘Femení’) then

ExempalrLleóFemella.allInstances()->exists(fem |

fem.nom = e.nom and fem.fèrtil = fèrtil)

endif

endif)
Jorge Borrás i Duarte & Pol Garrido Melis 08 / 05 / 2022

Context: Sistema::AltaZona(nomZ : String) : Zona

Pre:

Post: Zona.allInstances()->exists(z | z.nom = nomZ and z.oclIsNew() and result = z)

Context: Sistema::AltaEspècie(zona : Zona, nomE : String,

països: Set(país : String, estat : TipusEstat),

Pre: País.allInstances()->includeAll(països.país)

Post: Espècie.allInstances()->exists(esp | esp.nom = nomE and esp.oclIsNew()

and esp.país.nom = països.país and esp.zona->includes(zona) and

zona.espècie->includes(esp)) and

Localització.allInstances()->exists(l | l.espècie.nom = nomE and

països->exists(p | p.país = l.país.nom and p.estat = l.estatConservació)

and l.oclIsNew())
Jorge Borrás i Duarte & Pol Garrido Melis 08 / 05 / 2022

Context: Sistema::ConsultaAgressionsRellevants(nomEx : String) :

Set(TuplaType(dataA : Data, agredits: Set(String))

Pre: Exemplar.allInstances()->exists(ex | ex.nom = nomEx and

not Localització.allInstances()->exists(l | l.Espècie = ex.espècie and

l.estatConservació = EnPerillGreu)

Body: let result : Set(Agressió) =

Agressió.allInstances().->select( a | a.agressor.nom = nomE and

Localització.allInstances()->exists(l | l.espècie = a.agredit.espècie and

l.estatConservació = ‘EnPerillGreu’))

in result -> collect(a | Tupla { dataA = a.data.data;

adgredits = a.ferit.nom;})

You might also like