Update Attribute.h

This commit is contained in:
Brandon Jackson 2015-09-15 21:51:50 -05:00
parent 3a18ac0608
commit 51a7197b07

View file

@ -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;
}
*/
}; };