this is the copy&paste of the hw question for reference, no i do not want you to answer that. MY question is at the bottom of the thread
Class name is StudentModel has the attributes: a list of Student objects, size of the Student list (an integer), active status (a Boolean). The methods should include a constructor that loads the student data into the Student list from a data file, an add function that adds a student to the end of the list, a remove function that sets active status to false, a findPosition function that accepts a position in the list and returns a student’s first and last name at that given position (0 to list size minus 1), a findName function that accepts a last name and displays the full name and list position all of the students with the last name, a listSize function that returns the size of the list, a sort function that organizes the list by either student last name or average score.
a. Create a class diagram
b. Create the class specification/interface
c. Create a class implementation
i. Constructor loads the Student list from a data file
ii. An add function that adds a student to the end of the list
iii. A remove function that accepts student last name, calls the findName function and prompts the user to select position from the list, then sets active status to false if and only if the student name is found.
iv. A findPosition function that accepts a position in the list and returns a student’s first and last name at that given position (0 to list size minus 1
v. A findName function that accepts a last name and displays the full name and list position all of the students with the last name
vi. A listSize function that returns the size of the list,
vii. A sort function that organizes the list by either student last name or average score.
d. Add the class interface and implementation to a test driver
short parts of code of what im having issue understanding
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
class Student{
private:
string lastName;
string firstName;
bool activeStat;
public:
string getlastName();
void setlastName(string);
string getfirstName();
void setfirstName(string);
Student();
};
class StudentModel{
private:
Student students[];
int size;
public:
void setadd(string);
void setListSize(int size);
void setRemove(string);
void setAll(int, bool, string, string);
bool getRemove();
int getListSize();
void sort();
int findPosition(int);
void findName(string);
StudentModel();
};
void StudentModel::findName(string last) {
for (int i = 0; i < size; i++){
if (last == students[i].lastName){
cout << students[i].lastName << ", " << students[i].firstName << " ";
cout << "List position: " << i+1;
}
}
}
StudentModel::StudentModel() {
}
int main(){
StudentModel students[size];
return 0;
}
|
i havent finished the code for sure, though my question really is that the right way to access a array of objects ? can i use the new operator to dynamcailly allocate memory for this array ? she wants us to be able to add a new student to the end of the array, so maybe the new operator can help or should i switch over to vectors?