public abstract class Person {
protected String name;
protected int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
}
public class Student extends Person {
private int studentId;
public Student(String name, int age, int studentId) {
super(name, age);
this.studentId = studentId;
}
}
public interface Teachable {
void teach();
}
public class Teacher extends Person implements Teachable {
private String subject;
public Teacher(String name, int age, String subject) {
super(name, age);
this.subject = subject;
}
@Override
public void teach() {
System.out.println(name + " is teaching " + subject);
}
}
public class Course {
private String courseName;
private Teacher teacher;
public Course(String courseName, Teacher teacher) {
this.courseName = courseName;
this.teacher = teacher;
}
}
public class Department {
private String name;
private List<Teacher> teachers;
public Department(String name) {
this.name = name;
this.teachers = new ArrayList<>();
}
public void addTeacher(Teacher teacher) {
teachers.add(teacher);
}
}
public class School {
private final List<Department> departments;
public School() {
departments = new ArrayList<>();
departments.add(new Department("Math"));
departments.add(new Department("Science"));
}
}
public class GradeSystem {
public void recordGrade(Student student, Course course, int score) {
System.out.println("Recording grade for " + student.name + " in " + course);
}
}