Before I begin I wanted to give the heads up that this is a school assignment. I am not asking for it to be coded, a solution, or even a working example. I am more looking for help in code design or how you would setup these very simple tables.
The assignment is to put together two tables (very simple) in C++. To hopefully give more meaning to examples I may give here are the tables and what they include.
Students: Student ID, First Name, Last Name
Grades: Student ID, Term, Year, Grade
Only "requirement" that I must follow in designing and implementing this is that the tables are internally represented as a Linked List of rows. Note that I am allowed to use the std::list collection. I can only use the Standard Library though (boost or any other third party library not allowed) and it seems like our university compilers do not support C++11 at this time.
Question: Could I get clarification what this would mean?
What I think it would mean is this: Lets have I have the Student Table. Student Table has the attributes ID, First name, Last Name. Those attributes would be the "columns" in the table. You would then hold each of those attributes in a list. Would it be something like this?
// Quick Example, Class Not fully coded or represent final product
class Student
{
std::list<int> studentID;
std::list<std::string> firstName;
std::list<std::string> lastName;
}
Would that be right or did I read that wrong? Here is what is what the assignment states, though I am a bit confused by what she means.
"You will implement 2 tables, namely students and grades. Some of the design choices are up to you. You can either implement separate classes, implement a template, or implement a generic class for both row types (e.g. storing the attributes in a string array), etc. You will need one or multiple classes for the table and one or multiple classes for the corresponding rows, i.e. each table will internally be represented by a linked list of rows."
This is where I am getting a bit confused on a good way to design it and where I am asking for help. Collaborating with other people on some ideas always seems to help me when my brain isn't fully grasping a concept
I had some quick ideas that maybe some people would/could comment on to see if I am thinking about this correctly or if I am way off.
1: Just create a Table Class that represents a Table. I would just create two tables to represent the students and grades table. Issue I have with this is how to represent and store the attributes of each table. The reason I thought of this though is that to demonstrate the tables we will be issuing BASIC commands on the tables. Like print, to print the table. Select, to select a table, an attribute from that table, and the value, which would then print out all matching rows. We also can join the two tables together. Since each table has these commands seems like a Table Class would be good to hold these functions and not to repeat code.
2: Creating both a student and grades class that stores all the required information. Then create a StudentTable class that would store a list of Students and a GradesTable that would store a list of Grades
ie:
class Grades
{
int studentID;
std::string term;
int year;
char grade;
}
class GradesTable
{
std::list<Grades> studentGrades;
}
Any other ideas? Am I way off? Just some quick ideas and thoughts would be great.
Thanks ahead of time to all who try to help/comment!
Note: I did go talk to my professor though something about the way she explains things I tend to lose the grasp on the concept.