-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoardPiece.m
More file actions
37 lines (31 loc) · 1.02 KB
/
BoardPiece.m
File metadata and controls
37 lines (31 loc) · 1.02 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
classdef BoardPiece < handle
%BoardPiece is an abstract class that takes two inputs, a position and a
%board. It has a constructor that assigns the position to the Position
%property, and board to the MyBoard property. It has a die method which
%takes the current position and board of a block, and replaces it with an
%EmptySpace object. Finally, it has an abstract method getSym, which
%acquires a two-letter string depending on the type of block it is.
properties
Position;
MyBoard;
end
methods
function obj = BoardPiece(pos,bd)
if nargin == 2
obj.Position = pos;
bd.addPiece(obj);
obj.MyBoard = bd;
else
error('Incorrect number of inputs.')
end
end
function die(block)
pos = block.Position;
bd = block.MyBoard;
EmptySpace(pos,bd);
end
end
methods (Abstract)
pieceType = getSym(boardpiece);
end
end