-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrow.h
48 lines (41 loc) · 1 KB
/
row.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
/*
* row.h
*
* Created on: 07/12/2013
* Author: Jørgen Edelbo
*/
#ifndef ROW_H_
#define ROW_H_
#include "result.h"
#include <array>
#include <iostream>
#include <exception>
const int ROW_SIZE = 4;
const int NB_VAL = 6;
struct InvalidInput : std::exception {
InvalidInput(const char* errTxt) : mErrTxt(errTxt) {}
virtual const char* what() const noexcept { return mErrTxt; }
const char* mErrTxt;
};
class Row {
public:
Row();
Row(std::string str);
Result compare(const Row& r);
std::string rep();
bool operator==(const Row&);
private:
class CodePeg {
public:
CodePeg() : mVal(0) {}
void read(std::istream& istr);
void randomize();
void erase() { mVal = 0; }
bool operator==(const Row::CodePeg& other) const { return mVal == other.mVal; }
int mVal;
};
std::array<CodePeg,ROW_SIZE> mCodePegs;
friend std::ostream& operator <<(std::ostream& ostr, const Row::CodePeg&);
};
std::ostream& operator <<(std::ostream& ostr, const Row::CodePeg&);
#endif /* ROW_H_ */