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 {
|
||||
//a named column of a relation
|
||||
string name;
|
||||
string type;
|
||||
bool key;
|
||||
bool isKey;
|
||||
int size;
|
||||
|
||||
public:
|
||||
|
||||
vector<string> values;
|
||||
|
||||
Attribute(string n, string t, bool k){
|
||||
name = n;
|
||||
type = t;
|
||||
key = k;
|
||||
size = 0;
|
||||
}
|
||||
void initializeAttribute(string n, vector<string> a){
|
||||
|
||||
void addRow(string v) {
|
||||
values.push_back(v);
|
||||
name = n;
|
||||
values = a;
|
||||
}
|
||||
|
||||
string getName(){
|
||||
return name;
|
||||
}
|
||||
|
||||
string getType(){
|
||||
return type;
|
||||
}
|
||||
|
||||
bool isKey(){
|
||||
return key;
|
||||
}
|
||||
Attribute(){ }
|
||||
|
||||
void display()
|
||||
{
|
||||
cout<<"Atribute name:\t"<<name<<"\n";
|
||||
cout<<"Elements: ";
|
||||
|
||||
//cout<<"\nAtribute name:\t"<<name<<"\n";
|
||||
//cout<<"Elements: ";
|
||||
for (int i = 0; i < values.size(); ++i)
|
||||
{
|
||||
cout<<values[i]<<" ";
|
||||
|
@ -54,4 +42,33 @@ public:
|
|||
{
|
||||
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