Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.58 KB | None | 0 0
  1. /**
  2. * User
  3. *
  4. * Copyright (c) 2011, Christian Lysaker, Katrina Aquino
  5. * All Rights Reserved.
  6. *
  7. * Main Author: Katrina Aquino
  8. *
  9. * @version Last modified April 20, 2011
  10. */
  11.  
  12. package javamatcher.model;
  13.  
  14. import java.io.Serializable;
  15. import java.util.ArrayList;
  16. import java.util.Arrays;
  17. import java.util.Calendar;
  18. import java.util.Date;
  19.  
  20. /**
  21.  * This class contains personal information about a user.
  22.  */
  23. public class User implements Serializable {
  24.  
  25.     private static final long serialVersionUID = 7898L;
  26.     private String username;
  27.     private char[] password;
  28.     private String nationality;
  29.     private String city;
  30.     private String hairColor;
  31.     private String eyeColor;
  32.     private int height;
  33.     private Date birthdate;
  34.     private String job;
  35.     private String religion;
  36.     private ArrayList<String> interests;
  37.     private ArrayList<String> music;
  38.     private ArrayList<String> movies;
  39.     private String aboutMe;
  40.     private Gender gender;
  41.  
  42.     /**
  43.      * Constructs a new User.
  44.      *
  45.      * @param username  desired username.
  46.      * @param password  desired password.
  47.      * @param gender    users gender.
  48.      * @param nation    users nationality.
  49.      * @param city      the city nearest to where the user lives.
  50.      * @param hairColor hair color of the user
  51.      * @param eyeColor  eye color of the user
  52.      * @param height    height of the user
  53.      * @param birthdate the birthdate of the user
  54.      * @param job       the users current job
  55.      * @param religion  the users current religion
  56.      * @param interests list of interests
  57.      * @param music     list of preferred music genres
  58.      * @param movies    list of preferred movie genres
  59.      * @param aboutMe   short text about the current user.
  60.      */
  61.     public User(String username, char[] password, Gender gender,
  62.                 String nation, String city, String hairColor, String eyeColor,
  63.                 int height, Date birthdate, String job, String religion,
  64.                 ArrayList<String> interests, ArrayList<String> music,
  65.                 ArrayList<String> movies, String aboutMe) {
  66.  
  67.         this.username = username;
  68.         this.password = password;
  69.         this.gender = gender;
  70.         this.nationality = nation;
  71.         this.city = city;
  72.         this.hairColor = hairColor;
  73.         this.eyeColor = eyeColor;
  74.         this.height = height;
  75.         this.birthdate = birthdate;
  76.         this.job = job;
  77.         this.religion = religion;
  78.         this.interests = interests;
  79.         this.music = music;
  80.         this.movies = movies;
  81.         this.aboutMe = aboutMe;
  82.     }
  83.  
  84.     /**
  85.      * @return users username.
  86.      */
  87.     public String getUsername() {
  88.         return this.username;
  89.     }
  90.  
  91.     /**
  92.      * @return users gender.
  93.      */
  94.     public Gender getGender() {
  95.         return this.gender;
  96.     }
  97.  
  98.     /**
  99.      * Checks if the password re-entered matches the requested password.
  100.      *
  101.      * @param pass password
  102.      * @return true if passwords match.
  103.      */
  104.     public boolean isPasswordMatch(char[] pass) {
  105.         return Arrays.equals(this.password, pass);
  106.     }
  107.  
  108.  
  109.     /**
  110.      * @return the city the user is from.
  111.      */
  112.     public String getCity() {
  113.         return this.city;
  114.     }
  115.  
  116.     public void setCity(String city) {
  117.         this.city = city;
  118.     }
  119.  
  120.     /**
  121.      * @return users hair color.
  122.      */
  123.     public String getHairColor() {
  124.         return this.hairColor;
  125.     }
  126.  
  127.     /**
  128.      * @return users eye color.
  129.      */
  130.     public String getEyeColor() {
  131.         return this.eyeColor;
  132.     }
  133.  
  134.     /**
  135.      * @return users height
  136.      */
  137.     public int getHeight() {
  138.         return this.height;
  139.     }
  140.  
  141.     /**
  142.      * @return users age calculated from entered birthdate.
  143.      */
  144.     public int getAge() {
  145.  
  146.         Calendar dateOfBirth = Calendar.getInstance();
  147.  
  148.         dateOfBirth.setTime(this.birthdate);
  149.  
  150.         Calendar today = Calendar.getInstance();
  151.  
  152.         int age = today.get(Calendar.YEAR) - dateOfBirth.get(Calendar.YEAR);
  153.  
  154.         if (today.get(Calendar.DAY_OF_YEAR) >= dateOfBirth
  155.                 .get(Calendar.DAY_OF_YEAR))
  156.             age--;
  157.  
  158.         return age;
  159.     }
  160.  
  161.     /**
  162.      * @return the job of the current user.
  163.      */
  164.     public String getJob() {
  165.         return this.job;
  166.     }
  167.  
  168.     /**
  169.      * @return the nationality of the current user.
  170.      */
  171.     public String getNationality() {
  172.         return this.nationality;
  173.     }
  174.  
  175.     /**
  176.      * @return the religion of the current user.
  177.      */
  178.     public String getReligion() {
  179.         return this.religion;
  180.     }
  181.  
  182.     /**
  183.      * @return ArrayList of String which are the interests
  184.      *         checked during registration.
  185.      */
  186.     public ArrayList<String> getInterests() {
  187.         return this.interests;
  188.     }
  189.  
  190.     /**
  191.      * @return ArrayList of String which are the music genres
  192.      *         checked during registration.
  193.      */
  194.     public ArrayList<String> getMusic() {
  195.         return this.music;
  196.     }
  197.  
  198.     /**
  199.      * @return ArrayList of String which are the movie genres
  200.      *         checked during registration.
  201.      */
  202.     public ArrayList<String> getMovies() {
  203.         return this.movies;
  204.     }
  205.  
  206.     /**
  207.      * @return The short text the user writes about
  208.      *         themselves.
  209.      */
  210.     public String getAboutMe() {
  211.         return this.aboutMe;
  212.     }
  213.  
  214.     public Date getBirthdate() {
  215.         return this.birthdate;
  216.     }
  217.  
  218.     public void setNationality(String nationality) {
  219.         this.nationality = nationality;
  220.     }
  221.  
  222.     public void setHairColor(String hairColor) {
  223.         this.hairColor = hairColor;
  224.     }
  225.  
  226.     public void setEyeColor(String eyeColor) {
  227.         this.eyeColor = eyeColor;
  228.     }
  229.  
  230.     public void setPassword(char[] password) {
  231.         this.password = password;
  232.     }
  233.  
  234.     public void setHeight(int height) {
  235.         this.height = height;
  236.     }
  237.  
  238.     public void setBirthdate(Date birthdate) {
  239.         this.birthdate = birthdate;
  240.     }
  241.  
  242.     public void setJob(String job) {
  243.         this.job = job;
  244.     }
  245.  
  246.     public void setReligion(String religion) {
  247.         this.religion = religion;
  248.     }
  249.  
  250.     public void setInterests(ArrayList<String> interests) {
  251.         this.interests = interests;
  252.     }
  253.  
  254.     public void setMusic(ArrayList<String> music) {
  255.         this.music = music;
  256.     }
  257.  
  258.     public void setMovies(ArrayList<String> movies) {
  259.         this.movies = movies;
  260.     }
  261.  
  262.     public void setAboutMe(String aboutMe) {
  263.         this.aboutMe = aboutMe;
  264.     }
  265.  
  266.     public void setGender(Gender gender) {
  267.         this.gender = gender;
  268.     }
  269. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement