daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest Dec 19th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Student {
  2.     private String name;
  3.     private Integer age;
  4.     private String className;
  5.     private City city;
  6.     private List<String> subjects;
  7.  
  8.     public Student(String name, Integer age, String className, City city, List<String> subjects) {
  9.         this.name = name;
  10.         this.age = age;
  11.         this.className = className;
  12.         this.city = city;
  13.         this.subjects = subjects;
  14.     }
  15.  
  16.     public String getName() {
  17.         return name;
  18.     }
  19.  
  20.     public void setName(String name) {
  21.         this.name = name;
  22.     }
  23.  
  24.     public Integer getAge() {
  25.         return age;
  26.     }
  27.  
  28.     public void setAge(Integer age) {
  29.         this.age = age;
  30.     }
  31.  
  32.     public String getClassName() {
  33.         return className;
  34.     }
  35.  
  36.     public void setClassName(String className) {
  37.         this.className = className;
  38.     }
  39.  
  40.     public City getCity() {
  41.         return city;
  42.     }
  43.  
  44.     public void setCity(City city) {
  45.         this.city = city;
  46.     }
  47.  
  48.     public List<String> getSubjects() {
  49.         return subjects;
  50.     }
  51.  
  52.     public void setSubjects(List<String> subjects) {
  53.         this.subjects = subjects;
  54.     }
  55.  
  56.     @Override
  57.     public boolean equals(Object o) {
  58.         if (this == o) return true;
  59.         if (!(o instanceof Student)) return false;
  60.         Student student = (Student) o;
  61.         return name.equals(student.name) &&
  62.                 age.equals(student.age) &&
  63.                 className.equals(student.className) &&
  64.                 city.equals(student.city) &&
  65.                 subjects.equals(student.subjects);
  66.     }
  67.  
  68.     @Override
  69.     public int hashCode() {
  70.         return Objects.hash(name, age, className, city, subjects);
  71.     }
  72. }
  73.  
  74.  public class City {
  75.     private String name;
  76.  
  77.     public City(String name) {
  78.         this.name = name;
  79.     }
  80.  
  81.     public String getName() {
  82.         return name;
  83.     }
  84.  
  85.     public void setName(String name) {
  86.         this.name = name;
  87.     }
  88.  
  89.     @Override
  90.     public boolean equals(Object o) {
  91.         if (this == o) return true;
  92.         if (!(o instanceof City)) return false;
  93.         City city = (City) o;
  94.         return name.equals(city.name);
  95.     }
  96.  
  97.     @Override
  98.     public int hashCode() {
  99.         return Objects.hash(name);
  100.     }
  101. }
  102.  
  103. public class Solution {
  104.   Student s1 = new Student("Nick", 22, "A", new City("Kyiv"), asList("Math", "Physics", "History"));
  105.     Student s2 = new Student("Jack", 23, "A", new City("Odessa"), asList("Math", "Physics", "History"));
  106.     Student s3 = new Student("Danny", 23, "A", new City("Kyiv"), asList("Physics", "Geography"));
  107.     Student s4 = new Student("Hannah", 22, "B", new City("Odessa"), asList("History", "Computer Science"));
  108.     Student s5 = new Student("Sam", 21, "B", new City("Kyiv"), asList("History", "Math"));
  109.     Student s6 = new Student("Kate", 21, "B", new City("Odessa"), asList("Physics", "Computer Science"));
  110.     Student s7 = new Student("Danny", 22, "C", new City("Lviv"), asList("Computer Science", "Geography"));
  111.     Student s8 = new Student("Emily", 21, "C", new City("Lviv"), asList("Math", "Computer Science"));
  112.     Student s9 = new Student("Nick", 24, "C", new City("Kyiv"), asList("Computer Science"));
  113.     Student s10 = new Student("Joshua", 24, "C", new City("Kyiv"), asList("English"));
  114.     List<Student> studentsFixture = asList(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10);
  115.  
  116. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top