projet-bataille-navale/projet.use
2025-01-17 13:55:09 +01:00

127 lines
1.9 KiB
Text

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)
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 coordonne: x <= 10 and x > 0 and y > 0 and y <= 10
end
class Bateau
attributes
type: TypeBateau
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
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