Guest User

User Model

a guest
Jun 5th, 2017
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.99 KB | None | 0 0
  1. package com.computerScience.model;
  2.  
  3. /**
  4.  * Created by Sky_el on 31.05.2017.
  5.  */
  6. public class User {
  7.     private int userId;
  8.     private String name;
  9.     private String secondName;
  10.     private int age;
  11.     private boolean sex; // true - мужчина, false - женщина
  12.     private String school;
  13.     private String className;
  14.     private String email;
  15.     private String phone;
  16.     private String password;
  17.     private boolean isOnline;
  18.  
  19.     public User() { }
  20.  
  21.     public User(int userId, String name, String secondName, int age, boolean sex, String school,
  22.                 String className, String email, String phone, String password, boolean isOnline) {
  23.         this.userId = userId;
  24.         this.name = name;
  25.         this.secondName = secondName;
  26.         this.age = age;
  27.         this.sex = sex;
  28.         this.school = school;
  29.         this.className = className;
  30.         this.email = email;
  31.         this.phone = phone;
  32.         this.password = password;
  33.         this.isOnline = isOnline;
  34.     }
  35.  
  36.     public boolean isOnline() {
  37.         return isOnline;
  38.     }
  39.  
  40.     public void setOnline(boolean online) {
  41.         isOnline = online;
  42.     }
  43.  
  44.     public String getPhone() {
  45.         return phone;
  46.     }
  47.  
  48.     public void setPhone(String phone) {
  49.         this.phone = phone;
  50.     }
  51.  
  52.     public boolean getSex() {
  53.         return sex;
  54.     }
  55.  
  56.     public void setSex(boolean sex) {
  57.         this.sex = sex;
  58.     }
  59.  
  60.     public int getUserId() {
  61.         return userId;
  62.     }
  63.  
  64.     public void setUserId(int userId) {
  65.         this.userId = userId;
  66.     }
  67.  
  68.     public String getName() {
  69.         return name;
  70.     }
  71.  
  72.     public void setName(String name) {
  73.         this.name = name;
  74.     }
  75.  
  76.     public String getSecondName() {
  77.         return secondName;
  78.     }
  79.  
  80.     public void setSecondName(String secondName) {
  81.         this.secondName = secondName;
  82.     }
  83.  
  84.     public int getAge() {
  85.         return age;
  86.     }
  87.  
  88.     public void setAge(int age) {
  89.         this.age = age;
  90.     }
  91.  
  92.     public String getSchool() {
  93.         return school;
  94.     }
  95.  
  96.     public void setSchool(String school) {
  97.         this.school = school;
  98.     }
  99.  
  100.     public String getClassName() {
  101.         return className;
  102.     }
  103.  
  104.     public void setClassName(String className) {
  105.         this.className = className;
  106.     }
  107.  
  108.     public String getEmail() {
  109.         return email;
  110.     }
  111.  
  112.     public void setEmail(String email) {
  113.         this.email = email;
  114.     }
  115.  
  116.     public String getPassword() {
  117.         return password;
  118.     }
  119.  
  120.     public void setPassword(String password) {
  121.         this.password = password;
  122.     }
  123.  
  124.     @Override
  125.     public String toString() {
  126.         return "User{" +
  127.                 "userId=" + userId +
  128.                 ", name='" + name + '\'' +
  129.                 ", secondName='" + secondName + '\'' +
  130.                 ", age=" + age +
  131.                 ", sex=" + sex +
  132.                 ", school='" + school + '\'' +
  133.                 ", className='" + className + '\'' +
  134.                 ", email='" + email + '\'' +
  135.                 ", phone='" + phone + '\'' +
  136.                 ", password='" + password + '\'' +
  137.                 ", isOnline=" + isOnline +
  138.                 '}';
  139.     }
  140.  
  141.     @Override
  142.     public boolean equals(Object o) {
  143.         if (this == o) return true;
  144.         if (o == null || getClass() != o.getClass()) return false;
  145.  
  146.         User user = (User) o;
  147.  
  148.         if (userId != user.userId) return false;
  149.         if (age != user.age) return false;
  150.         if (sex != user.sex) return false;
  151.         if (isOnline != user.isOnline) return false;
  152.         if (name != null ? !name.equals(user.name) : user.name != null) return false;
  153.         if (secondName != null ? !secondName.equals(user.secondName) : user.secondName != null) return false;
  154.         if (school != null ? !school.equals(user.school) : user.school != null) return false;
  155.         if (className != null ? !className.equals(user.className) : user.className != null) return false;
  156.         if (email != null ? !email.equals(user.email) : user.email != null) return false;
  157.         if (phone != null ? !phone.equals(user.phone) : user.phone != null) return false;
  158.         return password != null ? password.equals(user.password) : user.password == null;
  159.     }
  160.  
  161.     @Override
  162.     public int hashCode() {
  163.         int result = userId;
  164.         result = 31 * result + (name != null ? name.hashCode() : 0);
  165.         result = 31 * result + (secondName != null ? secondName.hashCode() : 0);
  166.         result = 31 * result + age;
  167.         result = 31 * result + (sex ? 1 : 0);
  168.         result = 31 * result + (school != null ? school.hashCode() : 0);
  169.         result = 31 * result + (className != null ? className.hashCode() : 0);
  170.         result = 31 * result + (email != null ? email.hashCode() : 0);
  171.         result = 31 * result + (phone != null ? phone.hashCode() : 0);
  172.         result = 31 * result + (password != null ? password.hashCode() : 0);
  173.         result = 31 * result + (isOnline ? 1 : 0);
  174.         return result;
  175.     }
  176. }
Add Comment
Please, Sign In to add comment