Hello Community,
I currently try to solve a programming problem involving inheritance of multiple classes. Here is part of the problem statement:
Write a class named CourseGrades. The class should have a member named grades that is an array of GradedActivity pointers. The grades array should have four elements, one for each of the assignments previously described. |
Here is my class diagram:
https://ibb.co/eUO95c
My question/problem, if you will, revolves around the question what to do with CourseGrades class.
I tried to come up with arguments for and against the decision to have that class to be derived from the base class, which is GradedActivity. I could not find any argument, as a CourseGrade is no GradedActivity.
Then I thought about the possibility of making the CourseGrades a base class, which does not seem to fit the problem statement. With my still very limited knowledge I fail to see, how CourseGrades could become the base class AND allow for the possibility to have an array of pointers to GradedActivity objects.
So, the question, in short, is: Should CourseGrades be its own class, or should it be part of the whole, and if so, how? Or, rather, where to place it? Any help, links to topics I might find helpful (but lacking the correct vocabulary to look it up myself), is highly appreciated!
Here is the CourseGrades class file:
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
|
#ifndef COURSE_GRADES_H_
#define COURSE_GRADES_H_
#include "GradedActivity.h"
#include "PassFailExam.h"
#include "FinalExam.h"
#include "Essay.h"
#include <array>
const int NUM_OBJ = 4;
class CourseGrades
{
private:
std::array<GradedActivity *, NUM_OBJ> grades;
public:
CourseGrades() : grades{}
{
}
void setLab(GradedActivity *);
void setPassFailExam(PassFailExam *);
void setEssay(Essay *);
void setFinalExam(FinalExam *);
void print() const;
};
#endif
|