Created
November 26, 2025 05:50
-
-
Save untainsYD/6496ceb1d797de90fa393ee3458f798e to your computer and use it in GitHub Desktop.
Java advanced: Laboratory 3, Task4: class AcademicGroup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package ua.inf.iwanoff.java.advanced.lab3.model; | |
| import java.io.Serializable; | |
| import java.util.ArrayList; | |
| import java.util.Arrays; | |
| import java.util.List; | |
| import java.util.Objects; | |
| public class AcademicGroup implements Serializable { | |
| private String groupName; | |
| private List<Student> students = new ArrayList<>(); | |
| public AcademicGroup() { | |
| } | |
| public AcademicGroup(String groupName, List<Student> students) { | |
| this.groupName = groupName; | |
| this.students = students; | |
| } | |
| public String getGroupName() { | |
| return groupName; | |
| } | |
| public void setGroupName(String groupName) { | |
| this.groupName = groupName; | |
| } | |
| public List<Student> getStudents() { | |
| return students; | |
| } | |
| public void setStudents(List<Student> students) { | |
| this.students = students; | |
| } | |
| public void addStudent(Student student) { | |
| students.add(student); | |
| } | |
| @Override | |
| public String toString() { | |
| return "Group '" + groupName + "' " + students; | |
| } | |
| @Override | |
| public boolean equals(Object o) { | |
| if (this == o) | |
| return true; | |
| if (o == null || getClass() != o.getClass()) | |
| return false; | |
| AcademicGroup that = (AcademicGroup) o; | |
| return Objects.equals(groupName, that.groupName) && Objects.equals(students, that.students); | |
| } | |
| @Override | |
| public int hashCode() { | |
| return Objects.hash(groupName, students); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment