-
Notifications
You must be signed in to change notification settings - Fork 0
/
MoveList.h
55 lines (39 loc) · 985 Bytes
/
MoveList.h
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
#include "Move.h"
#include <iostream>
#ifndef CHESS_MOVELIST_H
#define CHESS_MOVELIST_H
class MoveList {
private:
Move *moves;
int size;
public:
MoveList();
MoveList(const MoveList &ml) : size(ml.size) {
moves = new Move[128];
for (int i = 0; i < 128; i++) {
moves[i] = ml.moves[i];
}
}
bool add(const Move &move);
bool clear();
int get_size() const { return size; }
bool in(Move & move) const;
Move &operator[]( int index) const {
if (index > size + 1) {
cerr << "RANGE ERROR";
throw exception();
}
return moves[index];
}
MoveList &operator=(const MoveList &rhs) {
if (this == &rhs)
return *this;
this->moves = new Move[128];
for (int i = 0; i < 128; i++) {
this->moves[i] = rhs.moves[i];
}
return *this;
}
virtual ~MoveList();
};
#endif //CHESS_MOVELIST_H