-
Notifications
You must be signed in to change notification settings - Fork 0
/
avNumeric.hpp
62 lines (58 loc) · 1.51 KB
/
avNumeric.hpp
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
// Author: Kristi Daigh
// Project: MLEM2 Rule Induction
// Date: 11/20/2019
/** Header file for the attribute-value
numeric block object. This is a subclass
of the block type.
@file avNumeric.hpp */
#ifndef AV_NUMERIC_H
#define AV_NUMERIC_H
#include "av.hpp"
#include <list>
#include <string>
#include <iostream>
#include <iomanip>
#include <sstream>
using namespace std;
class AVNumeric : public AV {
public:
AVNumeric(string attr, int attrCol, float minValue, float maxValue)
: AV(attr, attrCol) {
m_minValue = minValue;
m_maxValue = maxValue;
}
int getMinValue() const {
return m_minValue;
}
int getMaxValue() const {
return m_maxValue;
}
bool addOnMatch(Value * value, int x){
if(value->getNumValue() >= m_minValue && value->getNumValue() <= m_maxValue){
m_block.insert(x);
return true;
}
return false;
}
bool isNumeric() const {
return true;
}
void print() const {
cout << "[(" << m_attr << ", " << m_minValue << ".." << m_maxValue << ")] = {";
for(int caseNo : m_block){
cout << caseNo << ", ";
}
cout << "}" << endl;
}
std::string labelString() const {
stringstream stream;
stream << "(" << m_attr << ", ";
stream << setprecision(8) << m_minValue << "..";
stream << setprecision(8) << m_maxValue << ")";
return stream.str();
}
private:
float m_minValue;
float m_maxValue;
};
#endif