model projet_bataille_navale enum TypeCase { Vide, Bateau, Touche, Rate } enum TypeBateau { Torpilleur, Contre_Torpilleur, Croiseur, Porte_Avions } enum TypeCoup { Rate, Touche, Touche_Coule } enum EtatBateau { Operationnel, Coule } class Jeu operations init(nom1: String,nom2: String) debut() end class Joueur attributes Nom: String operations tirer(case: String): TypeCoup tirerRobot(): TypeCoup end class Flotte operations ajouterBateau(bateau: Bateau) constraints inv: bateaux->select(b: Bateau | b.type = TypeBateau::Torpilleur)->size() = 1 inv: bateaux->select(b: Bateau | b.type = TypeBateau::Contre_Torpilleur)->size() = 2 inv: bateaux->select(b: Bateau | b.type = TypeBateau::Croiseur)->size() = 1 inv: bateaux->select(b: Bateau | b.type = TypeBateau::Porte_Avions)->size() = 1 end class Coup attributes type: TypeCoup end class Plateau operations afficherPlateau(CacherBateaux: Boolean) end class Case attributes x: Integer y: Integer type: TypeCase operations changerEtat(nouveauEtat: TypeCase) getEtat(): TypeCase constraints 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 attributes type: TypeBateau longueur: Integer Etat: EtatBateau constraints 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 Joueur[1] role joueur Plateau[1] role plateau end composition Joue1 between Joueur[1] role joueur1 Jeu[1] role jeu2 end composition Joue2 between Joueur[1] role joueur2 Jeu[1] role jeu1 end association Tire between Joueur[*] role joueur Coup[1] role coups end association Appartient between Joueur[1] role joueur Flotte[1] role flotte end composition Appartient2 between Flotte[1] role flotte Bateau[*] role bateaux end composition Compose between Case[100] role cases Plateau[1] role plateau end association Etat between Case[1] role case Coup[1] role coup end association Repartit between Case[0..1] role cases Bateau[2..5] role bateau end