Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Student {
- private String name;
- private Integer age;
- private String className;
- private City city;
- private List<String> subjects;
- public Student(String name, Integer age, String className, City city, List<String> subjects) {
- this.name = name;
- this.age = age;
- this.className = className;
- this.city = city;
- this.subjects = subjects;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public Integer getAge() {
- return age;
- }
- public void setAge(Integer age) {
- this.age = age;
- }
- public String getClassName() {
- return className;
- }
- public void setClassName(String className) {
- this.className = className;
- }
- public City getCity() {
- return city;
- }
- public void setCity(City city) {
- this.city = city;
- }
- public List<String> getSubjects() {
- return subjects;
- }
- public void setSubjects(List<String> subjects) {
- this.subjects = subjects;
- }
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof Student)) return false;
- Student student = (Student) o;
- return name.equals(student.name) &&
- age.equals(student.age) &&
- className.equals(student.className) &&
- city.equals(student.city) &&
- subjects.equals(student.subjects);
- }
- @Override
- public int hashCode() {
- return Objects.hash(name, age, className, city, subjects);
- }
- }
- public class City {
- private String name;
- public City(String name) {
- this.name = name;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof City)) return false;
- City city = (City) o;
- return name.equals(city.name);
- }
- @Override
- public int hashCode() {
- return Objects.hash(name);
- }
- }
- public class Solution {
- Student s1 = new Student("Nick", 22, "A", new City("Kyiv"), asList("Math", "Physics", "History"));
- Student s2 = new Student("Jack", 23, "A", new City("Odessa"), asList("Math", "Physics", "History"));
- Student s3 = new Student("Danny", 23, "A", new City("Kyiv"), asList("Physics", "Geography"));
- Student s4 = new Student("Hannah", 22, "B", new City("Odessa"), asList("History", "Computer Science"));
- Student s5 = new Student("Sam", 21, "B", new City("Kyiv"), asList("History", "Math"));
- Student s6 = new Student("Kate", 21, "B", new City("Odessa"), asList("Physics", "Computer Science"));
- Student s7 = new Student("Danny", 22, "C", new City("Lviv"), asList("Computer Science", "Geography"));
- Student s8 = new Student("Emily", 21, "C", new City("Lviv"), asList("Math", "Computer Science"));
- Student s9 = new Student("Nick", 24, "C", new City("Kyiv"), asList("Computer Science"));
- Student s10 = new Student("Joshua", 24, "C", new City("Kyiv"), asList("English"));
- List<Student> studentsFixture = asList(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10);
- }
Add Comment
Please, Sign In to add comment