-3

I need help with an OCL operation to pass one of my master's subject. I do not know much about OCL language.

What I've to do is next:

Implement the operation:

Server::validMovement(playerName:String, movement:Movement):bool

This operation returns true if and only if exists a game who has one of its players with name playerName, that player would have the attribute hasTurn to true and the game board returns true when calling one operation validMovement(movement).

It's supposed that the operation Board:validMovement(g:Game):bool exists and it's NOT necessary documentary it in OCL.

Community
  • 1
  • 1

1 Answers1

2

Could it be something like that? I don't know if it's OK or not...

context Server :: validMovement(namePlayer:String, movement:Movement) : boolean

post : result = self.games->one(g : Game | p. players->exists(p : Player | p.name=namePlayer and p.hasTurn=true) and p.board.validMovement(movement))

P. Solar
  • 339
  • 3
  • 10