package ru.job4j;

public class UserSort implements Comparable<UserSort> {
    private String name;
    private int age;

    public UserSort(String name, int age) {
        this.age = age;
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public int compareTo(UserSort o) {
        return this.age < o.age ? 1 : -1;
      //  return Integer.compare(o.age,this.age);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        UserSort userSort = (UserSort) o;

        if (age != userSort.age) return false;
        return name != null ? name.equals(userSort.name) : userSort.name == null;
    }

    @Override
    public int hashCode() {
        int result = name != null ? name.hashCode() : 0;
        result = 31 * result + age;
        return result;
    }
}


@@ -515,32 +515,34 @@
 Sort o) %7B%0A      
+//
   return this.ag
@@ -567,26 +567,27 @@
 ;%0A      
-//  return
+  int res =
  Integer
@@ -612,16 +612,85 @@
 s.age);%0A
+        return res!=0 ? res : this.getName().compareTo(o.getName());%0A
     %7D%0A%0A 

task 10034.02