-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCLattice.cpp
More file actions
68 lines (52 loc) · 1.33 KB
/
CLattice.cpp
File metadata and controls
68 lines (52 loc) · 1.33 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
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
/*
* File: CLattice.cpp
* Author: Mark Wittekind
*
* Created on March 6, 2015, 11:51 AM
*/
#include "CLattice.h"
#include <iostream>
#include <string>
typedef std::vector<vector<bool> > NestedVector;
//#include "CObject.h"
using namespace std;
CLattice::CLattice(const unsigned short h, const unsigned short w) : CObject() {
m_height = h;
m_width = w;
for(unsigned short i = 0; i<=m_height; i++){
m_lattice.push_back(vector<bool>());
for(unsigned short j = 0; j<=m_width; j++){
m_lattice[i].push_back(false);
}
}
//NestedVector m_lattice(m_height,vector<bool>(m_width, 0));
}
CLattice::~CLattice() {
}
void CLattice::print_all(ostream& out_stream) {
const string TRUE_CHAR = " ";
const string FALSE_CHAR = "X";
for(unsigned short i = 1; i< m_height+1; i++){
string adjust = "";
if (i< 10)adjust = " ";
string newstring = adjust + to_string(i);
string header(" ");
if (i==1)
{
for(unsigned short j = 1; j<m_width+1; j++){
if(j<10)header+=" ";
header+= to_string(j);
header += " ";
}
header += "\n";
out_stream << header;
}
for(unsigned short j = 1; j<m_width+1; j++){
if(m_lattice[i][j])newstring+= " "+TRUE_CHAR+" ";
else newstring+= " "+FALSE_CHAR+" ";
}
newstring += "\n";
out_stream << newstring;
}
return;
}