SHARE
TWEET

Untitled

a guest May 31st, 2017 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package lapr.project.model;
  7.  
  8. import java.util.Random;
  9. import lapr.project.utils.DataEncryption;
  10.  
  11.  
  12. public class Utilizador {
  13.    
  14.     private int passKey;
  15.     private String m_sNome;
  16.     private String m_sEmail;
  17.     private String m_sUserName;
  18.     private String m_sPassword;
  19.     private Boolean m_bRegistado;
  20.    
  21.     public Utilizador()
  22.     {
  23.         this.passKey=getRandomPassKey();
  24.     }
  25.    
  26.     public Utilizador(String sNome, String sEmail, Boolean bRegistado)
  27.     {
  28.         this.passKey=getRandomPassKey();
  29.         this.m_sNome = sNome;
  30.         this.m_sEmail = sEmail;
  31.         this.m_sUserName = sEmail;
  32.         this.m_bRegistado = bRegistado;
  33.     }
  34.    
  35.     public Utilizador(String sNome, String sEmail, String sUsername, String sPassword) {
  36.         this.passKey=getRandomPassKey();
  37.         this.m_sNome = sNome;
  38.         this.m_sEmail = sEmail;
  39.         this.m_sPassword = sPassword;
  40.         this.m_sUserName = sUsername;
  41.         this.m_bRegistado = false;
  42.        
  43.     }
  44.     /*
  45.     public Utilizador(String sID, String sNome, String sEmail)
  46.     {
  47.         this.m_sNome = sNome;
  48.         this.m_sEmail = sEmail;
  49.         this.m_sUserName = sID;
  50.     } */
  51.    
  52.     public boolean hasID(String strId)
  53.     {
  54.         return m_sUserName.equalsIgnoreCase(strId);
  55.     }
  56.    
  57.     public String getID()
  58.     {
  59.         return m_sUserName;
  60.     }
  61.  
  62.     public String getNome() {
  63.         return m_sNome;
  64.     }
  65.  
  66.     public void setNome(String nome) {
  67.         this.m_sNome = nome;
  68.     }
  69.  
  70.     public String getEmail() {
  71.         return m_sEmail;
  72.     }
  73.  
  74.     public void setEmail(String email) {
  75.         this.m_sEmail = email;
  76.     }
  77.  
  78.     public String getUsername() {
  79.         return m_sUserName;
  80.     }
  81.  
  82.     public void setUsername(String username) {
  83.         this.m_sUserName = username;
  84.     }
  85.  
  86.     public String getPassword() {
  87.         return m_sPassword;
  88.     }
  89.  
  90.     public void setPassword(String password) {
  91.         this.m_sPassword = password;
  92.     }
  93.    
  94.  
  95.  
  96.     public Boolean getRegistado() {
  97.         return m_bRegistado;
  98.     }
  99.  
  100.     public void setRegistado(Boolean registado) {
  101.         this.m_bRegistado = registado;
  102.     }
  103.    
  104.     public static int getRandomPassKey(){
  105.         Random random = new Random();
  106.         int randomInt = random.nextInt(26)+1;
  107.         return randomInt;
  108.     }
  109.    
  110.     @Override
  111.     public String toString(){
  112.         return String.format("[%s, %s]", m_sNome, DataEncryption.desencriptarUsernameEmail(m_sUserName.toCharArray()));
  113.     }
  114.  
  115.     public boolean valida(){
  116.        
  117.         if (this.m_sNome.isEmpty() || this.m_sEmail.isEmpty() || this.m_sPassword.isEmpty() || this.m_sUserName.isEmpty() ) {
  118.            
  119.             return false;
  120.         }
  121.        
  122.         return true;
  123.     }
  124.  
  125.     @Override
  126.     public boolean equals(Object o)
  127.     {
  128.         if (this == o) {
  129.            
  130.             return true;
  131.         }
  132.         if (o == null) {
  133.            
  134.             return false;
  135.         }
  136.        
  137.         Utilizador other = (Utilizador) o;
  138.        
  139.         return (this.m_sEmail.equals(other.m_sEmail)) && (this.m_sUserName.equals(other.m_sUserName));
  140.     }
  141.  
  142.     /**
  143.      * @return the passKey
  144.      */
  145.     public int getPassKey() {
  146.         return passKey;
  147.     }
  148.  
  149.     /**
  150.      * @param passKey the passKey to set
  151.      */
  152.     public void setPassKey(int passKey) {
  153.         this.passKey = passKey;
  154.     }
  155.  
  156.  
  157.  
  158.    
  159.    
  160. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top