diff --git a/src/cathedra/Cathedra.java b/src/cathedra/Cathedra.java index f62da52..f57145b 100644 --- a/src/cathedra/Cathedra.java +++ b/src/cathedra/Cathedra.java @@ -1,6 +1,7 @@ package cathedra; +import account.Account; import faculty.Faculty; @@ -13,4 +14,8 @@ public interface Cathedra { void setName(String name); void setFaculty(Faculty faculty); + + Account getHead(); + + void setHead(Account head); } diff --git a/src/cathedra/CathedraImpl.java b/src/cathedra/CathedraImpl.java index 86648f5..2bab838 100644 --- a/src/cathedra/CathedraImpl.java +++ b/src/cathedra/CathedraImpl.java @@ -1,6 +1,9 @@ package cathedra; +import account.Account; +import account.Permission; +import account.RoleManager; import faculty.Faculty; import faculty.FacultyManager; @@ -11,7 +14,7 @@ public class CathedraImpl implements Cathedra { private String name; private Faculty faculty; - + private Account head; protected CathedraImpl(Faculty faculty, String name) { this.name = name; @@ -44,4 +47,17 @@ public void setFaculty(Faculty faculty) { this.faculty = faculty; } + @Override + public Account getHead() { + return this.head; + } + + @Override + public void setHead(Account head) { + if (!RoleManager.getInstance().hasPermission(head, Permission.InCathedra)) + throw new RuntimeException("Данный аккаунт не может быть заведующим кафедры."); + + this.head = head; + } + }