You are on page 1of 3

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

Exàmen 1)

Context: Sistema::AltaPlatIndividual(codi : String, nom : String, recepta : String

) : PlatIndividual

Pre:

Post: PlatIndividual.allInstances()->exists(p | p.oclIsNew() and p.codi = codi

and p.nom = nom and p.oclIsTypeOf(PlatIndividual) and p.recepta = recepta

and p.nombreMenús = 0 and result = p)

Context: Sistema::afegirIngredient(plat : PlatIndividual, nomIngredient : String,

quantitat : Decimal, unitatDeMesura : String)

Pre: Ingredient.allInstances()->exists(i | i.nom = nomIngredient)

Post: plat.ingredient.nom->includes(nomIngredient) and

Mesura.allInstances()->exists(m | m.oclIsNew() and

m.platindividual = plat and

m.ingredient.nom = nomIngredient and m.quantitat = quantitat

and m.unitatDeMesura = unitatDeMesura)


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

Context: Sistema::ConfeccióMenúDiari(nomR : String, data: Date, nomM : String,

preuM : Decimal, plats: Set(String))

Pre: Restaurant.allInstances()->exists(r | r.nom = nomR and

r.platIndividual.size() <= 100)

Post: if (not Menú.allInstances()@pre->exists(m | m.nom = nomM)) then

Menú.allInstances()->exists(m | m.nom = nomM and m.platindividual.nom =

plats and m.oclIsNew()) endif and

MenúDiariOfert.allInstances()->exists(m | m.oclIsNew() and

m.menú.nom = nomM and m.data = data and m.restaurant.nom= nomR and

m.preu = preuM)
Jorge Borrás i Duarte & Pol Garrido Melis 08 / 05 / 2022

Context: Sistema::ConsultaPlatsOferts(dataIni : Date, dataFi : Date,

nomR : String) : Set(TuplaType(codi : String, ingredients : (Set(String))))

Pre: MenúDiariOfert.allInstances()->select(m | m.restaurant.nom = nomR and

m.preu < 10).size() >= 10

Body: let result : Set(PlatsIndividuals) =

MenúDiariOfert.allInstances()->select(m | m.restaurant.nom = nomR and

m.data >= dataIni and m.data >= dateFi).menu.platsindividual

in result->collect(p | Tupla{ codi = p.codi;

ingredients = p.ingredient})

You might also like