hello, i'm confused here. i have an assignment that required me to create a project registration program that have student, project and supervisor. i haven't start to do it yet. but i've gone through the question. there's a part of the program that need to list out the student's, supervisor's and project's attributes that the user had enter. i thought of using vector to store all the attributes. but i don't think vector can do/store the attribute and list it out with something like this:

project's name: Computer
Supervisor: DR Stanley
Student Name: Robbinson
Student ID: 12345532

so, i'm not sure how to do for this part. can anyone explained to me what other method can i use? well, i know for this assignment, i need to use class and inheritance so far...

thank you

Member Avatar for iamthwee

Well vectors store objects so it has little to do with your question.

The main point is you need a class which will have various attributes.

You could then use a vector to store this although an array would be adequate as well.

Let's see some code first.

like iamthwee said, you should use a class in which you'll store as elements each of your requirements:
So you'll need some strings for the project name, supervisor name and student name, and some integer for the id.
After you do that class, let's call it ToBeStored, you should use the vector as this:

vector<ToBeStored> list;
ToBeStored obj;
list.push_back(obj);
class Project {
private: 
    string lec_name, stu_name, stu_id , project_name, Pro_startdate, Pro_duedate;

public:
    Project() {} // default constructor
    Project(string lec_name= "unknown", stu_name="unknown", stu_id="0" , project_name="no title",Pro_startdate="Null", Pro_duedate= "Null") {}; // overload constructor
    string getLecName(){return lec_name;} // get from class lecturer
    string getStuName(){return stu_name;}//get from student class
    string getStuID(){return stu_id;}//get from student class
    string getProName(){return project_name;}
    string getProStaDate(){return Pro_startdate;}
    string getProDueDate(){return Pro_duedate;}

}

this is how i implement the class. because the whole assignment need to have lecturer, student and project, so i need to implement three class right?

uh, can anyone explain about the constructor initializer list? well, i don't really know how to implement it.

thank you.

why don't you store them in the vector as objects of type class Project ?

yeah, but i have 3 class to create" lecturer, studenta and project.

how do i link them together? because i seen something like this:

class Player {
  int id;
  string name;
  string team;
 public:
  Player (int id, string name) : id(id), name(name), team("-") { }
  void print() const { cout << id << ", " << name << ", " << team << endl; }
  void setTeam (string team) { this->team = team; } 
};

class Team {
  string name;
  vector <Player> players;
 public:
  Team (string name) : name(name) { }
  void add (Player& player) {
    player.setTeam (name);
    players.push_back (player);
  }

and i have this:

class Project {
private: 
    string lec_name, stu_name, stu_id , project_name, Pro_startdate, Pro_duedate;

public:
    Project() {} // default constructor
    Project(string lec_name= "unknown", stu_name="unknown", stu_id="0" , project_name="no title",Pro_startdate="Null", Pro_duedate= "Null") {}; // overload constructor
    string getLecName(){return lec_name;} // get from class lecturer
    string getStuName(){return stu_name;}//get from student class
    string getStuID(){return stu_id;}//get from student class
    string getProName(){return project_name;}
    string getProStaDate(){return Pro_startdate;}
    string getProDueDate(){return Pro_duedate;}

}

class supervisor {
private:
    string lec_name, lec_ID, stu_name, stu_id, project_name; 

public: 
    supervisor() {} // default constructor
    supervisor(string lec_name= "unknown", lec_ID= "0", stu_name="unknown", stu_id="0" , project_name="no title") {}; // overload constructor
    string getLecName(){return lec_name;} 
    string getLecID(){return lec_ID;}
    string getStuName(){return stu_name;}//get from student class
    string getStuID(){return stu_id;}//get from student class
    string getProName(){return project_name;}//get from project class
}

class student {
private:
    string stu_name, stu_id, stu_faculty, stu_year, project_name, lec_name; 
public:
    student() {}//default constructor
    student(string stu_name= "unknown", stu_id= "0", stu_faculty= "Null",  lec_name="unknown", project_name="no title") {}; // overload constructor
    string getStuName(){return stu_name;}
    string getStuID(){return stu_id;}
    string getStuFal(){return stu_faculty;}
    string getLecName(){return lec_name;} //get from supervisor class
    string getProName(){return project_name;}//get from project class
}
Member Avatar for iamthwee

Just so we're clear can you post the exact requirements of your assignment. Normally teachers will be specific about what classes to create what methods they expect etc.

Problem Statement
You are hired to develop a Final Year Project (FYP) management system for a university. The business rules are listed below:
•        A student may register a project with a supervisor.
•        A project may have up to 2 students and must have 1 supervisor only.

The system must be able to perform the following functions:
1.      Create lecturers. [0.5m]
2.      Delete lecturers. [1m]
3.      Create students. [0.5m]
4.      Delete students. [1m]
5.      Create project. [0.5m]
6.      Delete project. [1m]
7.      Register a student to a supervisor for a project. [0.5m]
8.      Register project according to the quota. [1m]
9.      Unregister a student from a project. [1m]
10.  List all lecturers (all attributes, student, and project must be shown) [1m]
11.  List all students (all attributes, project, and supervisor must be shown) [1m]
12.  List all projects (all attributes, student, and supervisor must be shown) [1m]
13.  Read data from file and save data to file. [1m] (You may provide some initial data to facilitate testing during interview.)

may i know why i can't access the private member data even though i've declared public..

class Person {
private:
    string name;
    string id;
public:
    Person (string name, string id): name(name),id(id) {}
    string getName() {return name;}
    string getID() {return id;}
};


class Student : public Person {
private:
    string Student_year;
public:
    Student (string name, string id, string Student_year): Person(name), Person(id),Student_year(Student_year) {}
    string getStudent_year {return Student_year;}
    void print();

};

class Lecturer :  public Person {
private:
    string Room_number;
public:
    Lecturer (string name, string id, string Room_number): Person(name),Person(id), Room_number(Room_number) {}
    string getRoom_number {return Room_number;}
    void print();
};

class Project :  public Student,  public Lecturer {
public:
    Project (string name, string id) : Person(name), Person(id), Student( Student_year), Lecturer(Room_number) {}
    void print();
};

how do i eliminate that problem?

Try putting them as protected, and not as private, see if it helps.

what is it mean by the error called: function definition does not declare parameters, multiple initilization given for the base class and no matching function call to the superclass?

for the vector in the superclass i do something like this:
Inline Code Example Here

//superclass
class Person {
protected:
    string name;
    string id;
    vector <Person> info;
public:
    Person (string name, string id): name(name),id(id) {}// constructor initializer list

    string getName() {return name;}
    string getID() {return id;}
};

//subclass -> derived from superclass
class Student : virtual public Person {
protected:
    string Student_year;
public:
    Student (string name, string id, string Student_year): Person(name,id),Student_year(Student_year) {}

    string getStud_year() {return Student_year;}

then in the int main() when i want to create a student, do i do something like this in the int main?

 case '1' : cout<<"insert name"<<endl;
                        info.push_back(name);
                        cout<<"insert ID:"<<endl;
                        info.push_back(ID);
                        cout<<"insert year: 1. gamma , 2. delta"<<endl;
                        Student::info.push_back(Student_year);
                        break;

HacruLeian, are you still looking for help with this problem, or is it now too late (or solved)?

If you're still looking for help, where are you at with it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.