Reputation: 3
I understand what inherit does in Java Class Associations which is the extend feature. But I don't know what include means, I've researched and can only find implements but not sure if that's what includes means.
Here is the UML design.
StudentRecord (1) ---- includes ---- (1) Student FullTimeStudent (1) ---- inherits ----> (1) Student
Upvotes: 0
Views: 107
Reputation: 429
Here is the difference, technically:
First one: StudentRecord (1) ---- includes ---- (1) Student This means StudentRecord contains a member variable of type Student, something like
public class StudentRecord {
private Student student;
// and other member variables and functions
}
Second: FullTimeStudent (1) ---- inherits ----> (1) Student This means that FullTimeStudent is a Student. like:
public class FullTimeStudent extends Student {
// override stuff, add new members
}
See the difference? One says "contains", while the other "is a". i.e. you can write something like:
Student s = new FullTimeStudent();
and
StudentRecord sr = new StudentRecord(student);
// given you have such a constructor, or:
studentRecord.setStudent(s);
Upvotes: 3