Design template for adding a new class.

I have two classes: student and teacher, the student has one specific method: takeCourse; Teacher has one specific method: teaching.

Now I want to add a new class, GradStudent, which can take a course, such as Student, and can also teach a course, such as Teacher. Which template is the easiest way to implement this new class? Adapter, composite, delegate ....?

Thank.

+1
source share
1 answer

The question should be how to best model it, for which the answer will be "the way it makes sense in the real world", i.e. a grad student can also teach and take the course; -)

. , " ", " "

interface CanTeach
{
void teachCource();
}

class Teacher implements CanTeach {...}

class Student 
{
void takeCourse(...);
}

class GradStudent extends Student implements CanTeach
{
...
}
+2

All Articles