위 diagram을 변환해보자
class Course{
public int courseNo;
}
Course->CourseExecution의 관계는 성립하지 않음. 정보를 들고있을 필요가 없다.
abstract class UniversityMember{
public String firstName;
public String lastname;
public int ssNo;
}
class Student extends UniversityMember{
public int matNo;
public CourseExecution[] completedCourses;
}
Association이 있는 CourseExecution의 정보를, 여러개일수 있으니 배열 형태로 선언한다.
class Employee extends UniversityMember{
private int acctNo;
public int getAcctNo(){
#구현 내용
return acctNo;
}
public CourseExecution[] courseExecution;
}
위와 마찬가지로 배열형태 선언
class CourseExecution{
public int year;
public ESemester semester;
public Student[] student;
public Hashtable<Employee, ArrayList<>> support;
//key: Employee, value: (Erole role, float hours)
public Course course;
}
프로그래밍 언어에서는 Association Class를 지원하지 않기때문에, 한쪽에서 정보를 들고있으면 된다.
여기서는 해쉬테이블로 처리했다.
Course와의 단일 관계도 있기때문에 선언해주었다.
enum ESemester{
winter,
summer
}
enum ERole{
lecturer,
tutor,
examiner
}