Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * User
- *
- * Copyright (c) 2011, Christian Lysaker, Katrina Aquino
- * All Rights Reserved.
- *
- * Main Author: Katrina Aquino
- *
- * @version Last modified April 20, 2011
- */
- package javamatcher.model;
- import java.io.Serializable;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Calendar;
- import java.util.Date;
- /**
- * This class contains personal information about a user.
- */
- public class User implements Serializable {
- private static final long serialVersionUID = 7898L;
- private String username;
- private char[] password;
- private String nationality;
- private String city;
- private String hairColor;
- private String eyeColor;
- private int height;
- private Date birthdate;
- private String job;
- private String religion;
- private ArrayList<String> interests;
- private ArrayList<String> music;
- private ArrayList<String> movies;
- private String aboutMe;
- private Gender gender;
- /**
- * Constructs a new User.
- *
- * @param username desired username.
- * @param password desired password.
- * @param gender users gender.
- * @param nation users nationality.
- * @param city the city nearest to where the user lives.
- * @param hairColor hair color of the user
- * @param eyeColor eye color of the user
- * @param height height of the user
- * @param birthdate the birthdate of the user
- * @param job the users current job
- * @param religion the users current religion
- * @param interests list of interests
- * @param music list of preferred music genres
- * @param movies list of preferred movie genres
- * @param aboutMe short text about the current user.
- */
- public User(String username, char[] password, Gender gender,
- String nation, String city, String hairColor, String eyeColor,
- int height, Date birthdate, String job, String religion,
- ArrayList<String> interests, ArrayList<String> music,
- ArrayList<String> movies, String aboutMe) {
- this.username = username;
- this.password = password;
- this.gender = gender;
- this.nationality = nation;
- this.city = city;
- this.hairColor = hairColor;
- this.eyeColor = eyeColor;
- this.height = height;
- this.birthdate = birthdate;
- this.job = job;
- this.religion = religion;
- this.interests = interests;
- this.music = music;
- this.movies = movies;
- this.aboutMe = aboutMe;
- }
- /**
- * @return users username.
- */
- public String getUsername() {
- return this.username;
- }
- /**
- * @return users gender.
- */
- public Gender getGender() {
- return this.gender;
- }
- /**
- * Checks if the password re-entered matches the requested password.
- *
- * @param pass password
- * @return true if passwords match.
- */
- public boolean isPasswordMatch(char[] pass) {
- return Arrays.equals(this.password, pass);
- }
- /**
- * @return the city the user is from.
- */
- public String getCity() {
- return this.city;
- }
- public void setCity(String city) {
- this.city = city;
- }
- /**
- * @return users hair color.
- */
- public String getHairColor() {
- return this.hairColor;
- }
- /**
- * @return users eye color.
- */
- public String getEyeColor() {
- return this.eyeColor;
- }
- /**
- * @return users height
- */
- public int getHeight() {
- return this.height;
- }
- /**
- * @return users age calculated from entered birthdate.
- */
- public int getAge() {
- Calendar dateOfBirth = Calendar.getInstance();
- dateOfBirth.setTime(this.birthdate);
- Calendar today = Calendar.getInstance();
- int age = today.get(Calendar.YEAR) - dateOfBirth.get(Calendar.YEAR);
- if (today.get(Calendar.DAY_OF_YEAR) >= dateOfBirth
- .get(Calendar.DAY_OF_YEAR))
- age--;
- return age;
- }
- /**
- * @return the job of the current user.
- */
- public String getJob() {
- return this.job;
- }
- /**
- * @return the nationality of the current user.
- */
- public String getNationality() {
- return this.nationality;
- }
- /**
- * @return the religion of the current user.
- */
- public String getReligion() {
- return this.religion;
- }
- /**
- * @return ArrayList of String which are the interests
- * checked during registration.
- */
- public ArrayList<String> getInterests() {
- return this.interests;
- }
- /**
- * @return ArrayList of String which are the music genres
- * checked during registration.
- */
- public ArrayList<String> getMusic() {
- return this.music;
- }
- /**
- * @return ArrayList of String which are the movie genres
- * checked during registration.
- */
- public ArrayList<String> getMovies() {
- return this.movies;
- }
- /**
- * @return The short text the user writes about
- * themselves.
- */
- public String getAboutMe() {
- return this.aboutMe;
- }
- public Date getBirthdate() {
- return this.birthdate;
- }
- public void setNationality(String nationality) {
- this.nationality = nationality;
- }
- public void setHairColor(String hairColor) {
- this.hairColor = hairColor;
- }
- public void setEyeColor(String eyeColor) {
- this.eyeColor = eyeColor;
- }
- public void setPassword(char[] password) {
- this.password = password;
- }
- public void setHeight(int height) {
- this.height = height;
- }
- public void setBirthdate(Date birthdate) {
- this.birthdate = birthdate;
- }
- public void setJob(String job) {
- this.job = job;
- }
- public void setReligion(String religion) {
- this.religion = religion;
- }
- public void setInterests(ArrayList<String> interests) {
- this.interests = interests;
- }
- public void setMusic(ArrayList<String> music) {
- this.music = music;
- }
- public void setMovies(ArrayList<String> movies) {
- this.movies = movies;
- }
- public void setAboutMe(String aboutMe) {
- this.aboutMe = aboutMe;
- }
- public void setGender(Gender gender) {
- this.gender = gender;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement