package cmput301.textbookhub.Models;

import android.os.Bundle;

import java.util.Calendar;

import io.searchbox.annotations.JestId;

/**
 * Created by Fred on 2016/3/8.
 */
public class User implements NamedItem, UniqueItem<String>{

    private String username;
    private String password;
    private String email;
    private Long timestamp;

    private BookShelf bookShelf;

    public User(String username, String password) {
        this.username = username;
        this.password = password;
        this.timestamp = Calendar.getInstance().getTimeInMillis();
        this.bookShelf = new BookShelf();
    }

    public User(String username, String password, String email) {
        this.username = username;
        this.password = password;
        this.email = email;
        this.timestamp = Calendar.getInstance().getTimeInMillis();
        this.bookShelf = new BookShelf();
    }

    public User(String username, String password, BookShelf bookShelf) {
        this.username = username;
        this.password = password;
        this.timestamp = Calendar.getInstance().getTimeInMillis();
        if(bookShelf != null) {
            this.bookShelf = bookShelf;
        }else{
            this.bookShelf = new BookShelf();
        }
    }

    public User(String username, String password, BookShelf bookShelf, String email) {
        this.username = username;
        this.password = password;
        this.email = email;
        this.timestamp = Calendar.getInstance().getTimeInMillis();
        this.bookShelf = bookShelf;
        if(bookShelf != null) {
            this.bookShelf = bookShelf;
        }else{
            this.bookShelf = new BookShelf();
        }
    }

    @JestId
    protected String jid;

    @Override
    public String getName() {
        return this.username;
    }

    @Override
    public String getID() {
        return this.username;
    }

    @Override
    public void setID(String id) {
        this.username = id;
    }

    public BookShelf getBookShelf() {
        return bookShelf;
    }

    public String getEmail() {
        return email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Long getTimestamp() {
        return timestamp;
    }

    @Override
    public boolean equals(Object o) {
        if(o==null){
            return false;
        }
        if(o.getClass() != User.class){
            return false;
        }else{
            User user2 = (User) o;
            return this.username.equals(user2.getName());
        }
    }

    @Override
    public String toString() {
        return this.username;
    }

    public String getJid() {
        return jid;
    }

    public void setJid(String jid) {
        this.jid = jid;
    }
}

@@ -131,16 +131,322 @@
 d;%0A%0A/**%0A
+ * %3Ccode%3EUser%3C/code%3E is the user of the application, and contains lists of %3Ccode%3ETextbook%3C/code%3E.%0A * User has own and borrow textbooks. User can also bid on textbooks.%0A * %0A * @author Thirteam%0A * @version 1.1%0A * @since 2016/03/08%0A * @see Activity_UserProfile%0A * @see MyBidListAdapter%0A * @see Activity_Login%0A
  * Creat
@@ -469,16 +469,16 @@
 16/3/8.%0A
-
  */%0Apubl
@@ -681,16 +681,184 @@
 Shelf;%0A%0A
+    /**%0A     * User with unique username and password.%0A     * %0A     * @param username the username of the user%0A     * @param password the password of the user%0A     */ %0A
     publ
@@ -1077,32 +1077,255 @@
 Shelf();%0A    %7D%0A%0A
+    /**%0A     * User with a unique username, password, and an email.%0A     * %0A     * @param username the username of the user%0A     * @param password the password of the user%0A     * @param email the email of the user%0A     */ %0A
     public User(
@@ -2742,63 +2742,231 @@
     
-public String getEmail() %7B%0A        return email;%0A    %7D%0A
+/**%0A     * Return the user email.%0A     * %0A     * @return user email%0A     */ %0A    public String getEmail() %7B%0A        return email;%0A    %7D%0A%0A    /**%0A     * Return the user password.%0A     * %0A     * @return user password%0A     */ 
 %0A   

Update User.java