improved constraints

This commit is contained in:
Lukian 2025-01-17 14:08:36 +01:00
parent e471d47fd5
commit ebac675b3b

View file

@ -63,10 +63,8 @@ operations
changerEtat(nouveauEtat: TypeCase) changerEtat(nouveauEtat: TypeCase)
getEtat(): TypeCase getEtat(): TypeCase
constraints constraints
inv: inv: plateau.cases->select(c: Case | c.x = x and c.y = y)->size() = 1
plateau.cases->select(c: Case | c.x = x and c.y = y)->size() = 1 inv: x <= 10 and x > 0 and y > 0 and y <= 10
inv coordonne:
x <= 10 and x > 0 and y > 0 and y <= 10
end end
class Bateau class Bateau
@ -75,12 +73,10 @@ attributes
longueur: Integer longueur: Integer
Etat: EtatBateau Etat: EtatBateau
constraints constraints
inv longueur: inv: type = TypeBateau::Torpilleur implies longueur = 2
if type = TypeBateau::Torpilleur then longueur = 2 inv: type = TypeBateau::Contre_Torpilleur implies longueur = 3
else if type = TypeBateau::Contre_Torpilleur then longueur = 3 inv: type = TypeBateau::Croiseur implies longueur = 4
else if type = TypeBateau::Croiseur then longueur = 4 inv: type = TypeBateau::Porte_Avions implies longueur = 5
else longueur = 5
endif endif endif
end end
association Utilise between association Utilise between