Update Attribute.h
This commit is contained in:
parent
3a18ac0608
commit
51a7197b07
1 changed files with 38 additions and 21 deletions
57
Attribute.h
57
Attribute.h
|
@ -9,41 +9,29 @@ using namespace std;
|
||||||
class Attribute {
|
class Attribute {
|
||||||
//a named column of a relation
|
//a named column of a relation
|
||||||
string name;
|
string name;
|
||||||
string type;
|
bool isKey;
|
||||||
bool key;
|
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
vector<string> values;
|
vector<string> values;
|
||||||
|
|
||||||
Attribute(string n, string t, bool k){
|
void initializeAttribute(string n, vector<string> a){
|
||||||
name = n;
|
|
||||||
type = t;
|
|
||||||
key = k;
|
|
||||||
size = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void addRow(string v) {
|
name = n;
|
||||||
values.push_back(v);
|
values = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
string getName(){
|
string getName(){
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
string getType(){
|
Attribute(){ }
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isKey(){
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
void display()
|
void display()
|
||||||
{
|
{
|
||||||
cout<<"Atribute name:\t"<<name<<"\n";
|
//cout<<"\nAtribute name:\t"<<name<<"\n";
|
||||||
cout<<"Elements: ";
|
//cout<<"Elements: ";
|
||||||
|
|
||||||
for (int i = 0; i < values.size(); ++i)
|
for (int i = 0; i < values.size(); ++i)
|
||||||
{
|
{
|
||||||
cout<<values[i]<<" ";
|
cout<<values[i]<<" ";
|
||||||
|
@ -54,4 +42,33 @@ public:
|
||||||
{
|
{
|
||||||
return values.size();
|
return values.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pushBack(string s)
|
||||||
|
{
|
||||||
|
values.push_back(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void erase(int position)
|
||||||
|
{
|
||||||
|
values.erase(values.begin()+ position);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
Attribute(vector<string> v){
|
||||||
|
this.values = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
Attribute(const Attribute<string>& a){
|
||||||
|
this.values = a.getAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
Attribute& operator=(const Attribute<string>& a){
|
||||||
|
this.values = a.getAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
vector<string> getAll(){
|
||||||
|
return this.values;
|
||||||
|
}
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue