-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDepartment.java
More file actions
37 lines (32 loc) · 1.08 KB
/
Copy pathDepartment.java
File metadata and controls
37 lines (32 loc) · 1.08 KB
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
32
33
34
35
36
37
import java.io.*;
// Represents an academic department in the university
public class Department {
//Fields
private String code;
private String name;
private String description;
private AcademicMember head;
// Constructs a department with given code, name, and description
public Department(String code, String name, String description) {
this.code = code;
this.name = name;
this.description = description;
}
// Assigns the department head
public void setHead(AcademicMember head) {
this.head = head;
}
// Returns the department's name
public String getName() {
return name;
}
// Generates a report about the department
public String generateReport() {
StringWriter writer = new StringWriter();
writer.write("Department Code: " + code + "\n");
writer.write("Name: " + name + "\n");
writer.write("Head: " + (head != null ? head.getName() : "Not assigned") + "\n");
writer.write("\n");
return writer.toString();
}
}