-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponents.h
38 lines (36 loc) · 966 Bytes
/
components.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
#include "random.h"
#include <iostream>
class dot{
public:
dot();
dot( int _x, int _y=0, char _flag='+' );
int x;
int y;
int age=0;
char flag; // flag '+' means dead resident
int strength;
bool is_newborn = true;
bool operator==( const dot &rhs );
// std::ostream& operator<<( std::ostream& os, const dot &rhs );
private:
char _empty = ' ';
char _death = _empty;
int direction;
};
bool dot::operator==( const dot &rhs ){
return this->x == rhs.x && this->y == rhs.y;
}
std::ostream& operator<<( std::ostream& os, const dot &rhs ){
os << rhs.x << "," << rhs.y << "|" << rhs.flag;
return os;
}
dot::dot()
: x(0), y(0), flag('+')
{
Random r; r.seed(); strength = r.range(0,100);
}
dot::dot( int _x, int _y, char _flag )
: x(_x), y(_y), flag(_flag)
{
Random r; r.seed(); strength = r.range(0,100);
}