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