diff --git a/Attribute.h b/Attribute.h index 2c1bd3d..9d53d4c 100755 --- a/Attribute.h +++ b/Attribute.h @@ -1,37 +1,47 @@ -#include -#include - -using namespace std; - -//Funtional, might need more functionality - -template -class Attribute { - //a named column of a relation - string name; - vector values; - bool isKey; - int size; -public: - Attribute(){ } - - Attribute(vector v){ - this.values = v; - } - - Attribute(const Attribute& a){ - this.values = a.getAll(); - } - - Attribute& operator=(const Attribute& a){ - this.values = a.getAll(); - } - - string getName(){ - return name; - } - - vector getAll(){ - return this.values; - } -}; \ No newline at end of file +#include +#include + +using namespace std; + +//Funtional, might need more functionality + +//template +class Attribute { + //a named column of a relation + string name; + + bool isKey; + int size; + +public: + + vector values; + + void initializeAttribute(string n, vector a){ + + name = n; + values = a; + } + + string getName(){ + return name; + } + + Attribute(){ } + + void display() + { + cout<<"Atribute name:\t"< getElements(){ + return values; + } + */ +}; diff --git a/DBEngine.h b/DBEngine.h index 9ec458b..32e96c2 100755 --- a/DBEngine.h +++ b/DBEngine.h @@ -4,7 +4,7 @@ #include "Relation.h" using namespace std; - + class DBEngine { //member variables //NOT DONE diff --git a/Relation.h b/Relation.h index 222b8a5..c41db03 100755 --- a/Relation.h +++ b/Relation.h @@ -1,16 +1,47 @@ -#include -#include -#include "Attribute.h" - -using namespace std; - -//NOT DONE -class Relation { - //a table with rows and columns - string name; - vector< Attribute > att; -public: - Relation(); - Relation(vector< Attribute > a) { att = a; } - void addTuple(vector< Attribute > tuple); -}; \ No newline at end of file +#include +#include +#include "Attribute.h" + +using namespace std; + +//NOT DONE +class Relation { + //a table with rows and columns + string name; //The title the user gives it + vector< Attribute > att; //A vector of the columns + +public: + Relation(); + + //constructor + Relation(string n, vector< Attribute > a) { + name = n; + att = a; + } + + void addTuple(vector< string > tuple) { + + //Loop through the attribute columns + for(int i = 0; i < att.size(); i++) { + + //Loop through the elements in the i'th column + for(int j = 0; j < att[i].values.size(); j++){ + + //In this column, at this element's spot, assign an element from the tuple vector to this spot + (att[i].values[j]).assign(tuple[i]); + } + } + } + + void displayTableName() { + cout << "The table name is: " << name << endl; + } + + vector< Attribute > getAttributes(){ + return att; + } + + int getSize() { + return att.size(); + } +}; diff --git a/test.cpp b/test.cpp index a419a4a..b6b03b0 100755 --- a/test.cpp +++ b/test.cpp @@ -1,10 +1,44 @@ #include -#include "DBEngine.h" +//#include "DBEngine.h" +#include +#include "Attribute.h" using namespace std; -int main() { +int main() { + + /* DBEngine engine; Relation r; - Attribute a; + Attribute a; + */ + + vector shamWow; + shamWow.push_back("rag"); + shamWow.push_back("sponge"); + shamWow.push_back("wooow"); + shamWow.push_back("cloth"); + + Attribute atributo; + atributo.initializeAttribute("atributo",shamWow); + atributo.display(); + + vector doom; + doom.push_back("zombieman"); + doom.push_back("revenant"); + doom.push_back("imp"); + doom.push_back("archvile"); + + Attribute atributo2; + atributo2.initializeAttribute("attribute_2", doom); + atributo2.display(); + + + + + string line1 = "Table_1"; + + + + //Relation r(line1, my_attributes); }