-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCore.Card.pas
More file actions
59 lines (47 loc) · 1.1 KB
/
Core.Card.pas
File metadata and controls
59 lines (47 loc) · 1.1 KB
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
unit Core.Card;
interface
type
ICard = interface
['{1BD19858-F354-498C-AF3D-E363122019A3}']
function GetFacingUp : boolean;
function Flip : boolean;
property FacingUp : boolean read GetFacingUp;
end;
TCard = class(TInterfacedObject, ICard)
private
FFacingUp : boolean;
public
constructor Create;
function GetFacingUp : boolean;
function Flip : boolean;
function TurnFaceDown : boolean;
end;
implementation
{ TCard }
constructor TCard.Create;
begin
inherited;
//By default the card is facing up.
FFacingUp := True;
end;
function TCard.Flip: boolean;
begin
//Change the card from facing the way it is to the facing the other way.
//A card can either be facing up, or down.
FFacingUp := not FFacingUp;
//Return the current facing up status.
result := FFacingUp;
end;
function TCard.GetFacingUp: boolean;
begin
//Return whether the card is facing up or not.
result := FFacingUp;
end;
function TCard.TurnFaceDown: boolean;
begin
//Make the card face down.
FFacingUp := false;
//Return the current facing up status.
result := FFacingUp;
end;
end.