-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.vdmpp
85 lines (72 loc) · 1.59 KB
/
Player.vdmpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
class Player
types
public PlayerNumber = nat1;
public Score = nat;
values
instance variables
private number: PlayerNumber;
private score: Score := 0;
private piecesOut: nat := 0;
private piecesFinal: nat := 0;
--invariantes
inv number in set {1,2};
inv score >= 0;
inv piecesOut >= 0 and piecesOut <= 5;
inv piecesFinal >= 0 and piecesFinal <= 5
operations
--construtor de um Jogador
public Player : PlayerNumber ==> Player
Player(num) == (
number := num;
return self
)
post number in set {1,2};
--retorna numero do jogador
pure public getNumber : () ==> PlayerNumber
getNumber() == (
return number;
);
--retornar pecas fora do tabuleiro
pure public getPiecesOut : () ==> nat
getPiecesOut() == (
return piecesOut;
);
--retornar pecas na linha do adversario
pure public getPiecesFinal : () ==> nat
getPiecesFinal() == (
return piecesFinal;
);
--contagem de pecas na linha do adversario
public addPiecesFinal : () ==> ()
addPiecesFinal() == (
piecesFinal := piecesFinal + 1;
)
post piecesFinal <= 5;
public subPiecesFinal : () ==> ()
subPiecesFinal() == (
piecesFinal := piecesFinal - 1;
)
post not piecesFinal < 0;
--contagem de pecas fora do tabuleiro
public addPiecesOut : () ==> ()
addPiecesOut() == (
piecesOut := piecesOut + 1;
)
post piecesOut <= 5;
public subPiecesOut : () ==> ()
subPiecesOut() == (
piecesOut := piecesOut - 1;
)
post not piecesOut < 0;
--atribuir pontuacao
public setScore : nat ==> ()
setScore(sc) == (
score := sc;
)
pre sc >= 0;
--retornar pontuacao
pure public getScore : () ==> nat
getScore() == (
return score;
);
end Player