Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. /**
  2. * La classe Registrazione rappresenta una registrazione. Lo stato della classe consiste nei dati anagrafici dell'utente (nome, cognome, sesso)
  3. * e credenziali d'accesso (email, password), i cui valori sono stringhe inizialmente nulle.
  4. *
  5. * La classe permette di inserire i dati anagrafici e le credenziali d'accesso.
  6. *
  7. * @author rvene
  8. *
  9. */
  10. public class Registrazione {
  11. private String nome;
  12. private String cognome;
  13. private String sesso;
  14. private String email;
  15. private String password;
  16.  
  17. /**
  18. * @param cognome
  19. * @param nome
  20. * @param password
  21. * @param sesso
  22. * @param email
  23. *
  24. */
  25. public Registrazione() {
  26. this.cognome=null;
  27. this.nome=null;
  28. this.password=null;
  29. this.sesso=null;
  30. this.email=null;
  31. }
  32.  
  33. public String getNome() {
  34. return nome;
  35. }
  36.  
  37. /**
  38. * Inserisce il nome dell'utente
  39. * @param name: nome da inserire
  40. * @throws IllegalArgumentException: se si inserisce una stringa uguale a zero o maggiore di venti
  41. */
  42. public void inserisciNome(String name) throws IllegalArgumentException {
  43. if(name.length()==0)
  44. throw new IllegalArgumentException("Nome vuoto");
  45. if(name.length()>20)
  46. throw new IllegalArgumentException("Nome troppo breve");
  47. this.nome=name;
  48. }
  49.  
  50. public String getCognome() {
  51. return cognome;
  52. }
  53. /**
  54. * Inserisce il cognome dell'utente
  55. * @param surname: cognome da inserire
  56. * @throws IllegalArgumentException: se si inserisce una stringa uguale a zero o maggiore di venti
  57. */
  58. public void inserisciCognome(String surname) throws IllegalArgumentException{
  59. if(surname.length()==0)
  60. throw new IllegalArgumentException("Cognome vuoto");
  61. if(surname.length()>20)
  62. throw new IllegalArgumentException("Cognome troppo lungo");
  63. this.cognome=surname;
  64. }
  65.  
  66.  
  67. public String getSesso() {
  68. return sesso;
  69. }
  70. /**
  71. * Inserisce il sesso dell'utente
  72. * @param ses: sesso da inserire
  73. * @throws IllegalArgumentException: se non si inserisce una stringa uguale alla stringa "maschio" o alla stringa "donna"
  74. */
  75. public void inserisciSesso(String ses) throws IllegalArgumentException {
  76. if(sesso.equals("Maschio") || sesso.equals("Femmina"))
  77. this.sesso = ses;
  78. else
  79. throw new IllegalArgumentException("non hai selezionato il sesso");
  80. }
  81.  
  82. public String getEmail() {
  83. return email;
  84. }
  85. public void setEmail(String email) {
  86. this.email = email;
  87. }
  88.  
  89. public String getPassword() {
  90. return password;
  91. }
  92.  
  93. /**
  94. * Inserisce la password dell'utente
  95. * @param pass: password da inserire
  96. * @throws IllegalArgumentException: se si inserisce una stringa uguale a 0 o maggiore di 8
  97. */
  98. public void inserisciPassword(String pass) throws IllegalArgumentException{
  99. if(pass.length()==0)
  100. throw new IllegalArgumentException("Password vuota");
  101. if( pass.length()>8)
  102. throw new IllegalArgumentException("Password troppo lunga");
  103. this.password=pass;
  104. }
  105.  
  106.  
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement