Advertisement
Guest User

Untitled

a guest
Mar 12th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.49 KB | None | 0 0
  1. package me.mahtaran.Signature;
  2.  
  3. import java.time.LocalDate;
  4.  
  5. public class Signature {
  6.     public String getTitle(final Human human) {
  7.     if (human.equals(Human.NOTCH) || human.equals(Human.JEB_) || human.equals(Human.DINNERBONE)
  8.         || human.equals(Human.GOD))
  9.         return "Almighty lord";
  10.     if (human.equals(Human.ME))
  11.         return "Almighty handsome lord of everything that has and shall ever live";
  12.     if (human.age - Human.ME.age > 10)
  13.         return human.gender.equals(Gender.MALE) ? "Sir"
  14.             : human.gender.equals(Gender.FEMALE) ? "Miss" : "WTF are you?";
  15.     return "nub :D";
  16.     }
  17.  
  18.     public static int getDiffYears(final LocalDate first, final LocalDate last) {
  19.     int diff = last.getYear() - first.getYear();
  20.     if (first.getMonthValue() > last.getMonthValue()
  21.         || first.getMonthValue() == last.getMonthValue() && first.getDayOfMonth() > last.getDayOfMonth())
  22.         diff--;
  23.     return diff;
  24.     }
  25.  
  26.     public enum Human {
  27.     NOTCH(getDiffYears(LocalDate.of(1979, 6, 1), LocalDate.now()), Gender.MALE),
  28.     JEB_(getDiffYears(LocalDate.of(1979, 5, 18), LocalDate.now()), Gender.MALE),
  29.     DINNERBONE(getDiffYears(LocalDate.of(1991, 6, 23), LocalDate.now()), Gender.MALE),
  30.     GOD(Integer.MAX_VALUE, Gender.UNKNOWN),
  31.     ME(getDiffYears(LocalDate.of(2003, 4, 24), LocalDate.now()), Gender.MALE);
  32.  
  33.     public int age;
  34.     public Gender gender;
  35.  
  36.     private Human(final int age, final Gender gender) {
  37.         this.age = age;
  38.         this.gender = gender;
  39.     }
  40.     }
  41.  
  42.     public enum Gender {
  43.     MALE, FEMALE, UNKNOWN;
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement