Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * La classe Registrazione rappresenta una registrazione. Lo stato della classe consiste nei dati anagrafici dell'utente (nome, cognome, sesso)
- * e credenziali d'accesso (email, password), i cui valori sono stringhe inizialmente nulle.
- *
- * La classe permette di inserire i dati anagrafici e le credenziali d'accesso.
- *
- * @author rvene
- *
- */
- public class Registrazione {
- private String nome;
- private String cognome;
- private String sesso;
- private String email;
- private String password;
- /**
- * @param cognome
- * @param nome
- * @param password
- * @param sesso
- * @param email
- *
- */
- public Registrazione() {
- this.cognome=null;
- this.nome=null;
- this.password=null;
- this.sesso=null;
- this.email=null;
- }
- public String getNome() {
- return nome;
- }
- /**
- * Inserisce il nome dell'utente
- * @param name: nome da inserire
- * @throws IllegalArgumentException: se si inserisce una stringa uguale a zero o maggiore di venti
- */
- public void inserisciNome(String name) throws IllegalArgumentException {
- if(name.length()==0)
- throw new IllegalArgumentException("Nome vuoto");
- if(name.length()>20)
- throw new IllegalArgumentException("Nome troppo breve");
- this.nome=name;
- }
- public String getCognome() {
- return cognome;
- }
- /**
- * Inserisce il cognome dell'utente
- * @param surname: cognome da inserire
- * @throws IllegalArgumentException: se si inserisce una stringa uguale a zero o maggiore di venti
- */
- public void inserisciCognome(String surname) throws IllegalArgumentException{
- if(surname.length()==0)
- throw new IllegalArgumentException("Cognome vuoto");
- if(surname.length()>20)
- throw new IllegalArgumentException("Cognome troppo lungo");
- this.cognome=surname;
- }
- public String getSesso() {
- return sesso;
- }
- /**
- * Inserisce il sesso dell'utente
- * @param ses: sesso da inserire
- * @throws IllegalArgumentException: se non si inserisce una stringa uguale alla stringa "maschio" o alla stringa "donna"
- */
- public void inserisciSesso(String ses) throws IllegalArgumentException {
- if(sesso.equals("Maschio") || sesso.equals("Femmina"))
- this.sesso = ses;
- else
- throw new IllegalArgumentException("non hai selezionato il sesso");
- }
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public String getPassword() {
- return password;
- }
- /**
- * Inserisce la password dell'utente
- * @param pass: password da inserire
- * @throws IllegalArgumentException: se si inserisce una stringa uguale a 0 o maggiore di 8
- */
- public void inserisciPassword(String pass) throws IllegalArgumentException{
- if(pass.length()==0)
- throw new IllegalArgumentException("Password vuota");
- if( pass.length()>8)
- throw new IllegalArgumentException("Password troppo lunga");
- this.password=pass;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement