-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBufferType1.cpp
55 lines (49 loc) · 1.84 KB
/
BufferType1.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
#include "BufferType1.h"
BufferType1::BufferType1()
{
planex = std::make_pair(0, 0);
planey = std::make_pair(0, 2);
planez = std::make_pair(3, 6);
}
std::pair<int,int> BufferType1::read(char value) //returns coordinates of value passed (X, Y, or Z)
{
if(value == 'X') { //if wanting coordinates of X
return planex;
}
else if(value == 'Y') { //if wanting coordinates of Y
return planey;
}
else if(value == 'Z') { //if wanting coordinates of Z
return planez;
}
std::cout << "Error: invalid value supplied -- cannot read from \'" << value << "\'" << std::endl;
return std::make_pair(-1,-1);
}
void BufferType1::write(char value, int row, int col) // writes values to selected plane type
{
if ((row <= 7 && col <=6) && (row >= 0 && col >= 0)) { // make sure we are in bounds
if (value == 'X') {
planex.first = row;
planex.second = col;
} if (value == 'Y') {
planey.first = row;
planey.second = col;
} if (value == 'Z') {
planez.first = row;
planez.second = col;
}
// std::cout << "wrote!" << std::endl;
}
else {
std::cout
<< "Error: invalid value supplied. This is actually pretty hard to do. Unfortunately, the program will die now."
<< std::endl;
exit(EXIT_FAILURE);
}
}
void BufferType1::print() //for testing purposes
{
std::cout << "Plane X coordinates (row, column): (" << planex.first << ", " << planex.second << ")" << std::endl;
std::cout << "Plane Y coordinates (row, column): (" << planey.first << ", " << planey.second << ")" << std::endl;
std::cout << "Plane Z coordinates (row, column): (" << planez.first << ", " << planez.second << ")" << std::endl;
};