-
Notifications
You must be signed in to change notification settings - Fork 0
/
robot.cpp
76 lines (69 loc) · 1.33 KB
/
robot.cpp
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
//T09_G12
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <stdio.h>
#include <chrono>
#include <iomanip>
#include <algorithm>
//our files
#include "Robot.h"
#include "Move_pos.h"
//constructor
Robot::Robot() {
row = -1;
col = -1;
id = -1;
alive = true;
}
Robot::Robot(int ID, int row_input,int col_input){
row = row_input;
col = col_input;
id = ID;
alive = true;
}
//getters
int Robot::getID() const { return id; }
int Robot::getRow() const {return row;}
int Robot::getCol() const {return col;}
char Robot::getSymbol() const {
if (alive==true){
return alive_robot;
}
else{
return dead_robot;
}
}
Position Robot::getPosition() const {
Position robot_return;
robot_return.row = row;
robot_return.col = col;
return robot_return;
}
bool Robot::isAlive() const {return alive;} //returns robot condition
//setter
void Robot::setRow(int x){
row = x;
}
void Robot::setCol(int y){
col = y;
}
void Robot::setID(char ID) {
id = ID;
}
void Robot::setPosition(const Position &pos){
row = pos.row;
col = pos.col;
}
//robot movement
void Robot::robotMove(Movement delta) {
row = row + delta.dRow;
col = col + delta.dCol;
}
//set robot dead
void Robot::setAsDead(){
alive = false;
}