Example #1
0
  public void cadastrarTime(Time time)
      throws UsuarioCurtoException, UsuarioLongoException, UsuarioExistenteException,
          SenhaCurtaException, SenhaLongaException {
    boolean usuarioExistente = (Boolean) null;
    boolean nomeUsuarioJaExiste = (Boolean) null;

    if (time == null) {
      throw new IllegalArgumentException(); // o que fazer quando null?
    } else {
      if (Utilidades.nomeUsuarioNosConformes(time.getUsuario())) {

      } else {
        throw new UsuarioCurtoException();
      }

      Utilidades.nomeNosConformes(time.getNome());

      // chamar método nomeUsuarioNosConforme e senha tb.
      nomeUsuarioJaExiste = repositorioTime.verificarNomeUsuarioJaExiste(time.getUsuario());
      if (usuarioExistente == false && nomeUsuarioJaExiste == false) {
        repositorioTime.cadastrarTime(time);
      } else if (usuarioExistente) {
        throw new UsuarioExistenteException();
      }
      if (nomeUsuarioJaExiste) {
        throw new UsuarioExistenteException();
      }
    }
  }
Example #2
0
 public void atualizarTime(Time time) throws TimeNaoEncontradoException, IllegalArgumentException {
   Time t;
   int index;
   if (time != null) {
     t = repositorioTime.retornarTime(time.getUsuario());
     index = repositorioTime.procurarIndice(time);
   } else {
     throw new IllegalArgumentException();
   }
   if (index != -1 && t != null) {
     repositorioTime.atualizarTime(t, index);
   } else {
     throw new TimeNaoEncontradoException();
   }
 }
Example #3
0
 public void removerTime(Time time) throws UsuarioNaoEncontradoException {
   // List<Olheiro> olheirosContratados = null;
   if (time != null) {
     int index = repositorioTime.procurarIndice(time);
     if (index != -1) {
       /*	TimesASeremRemovidos = repositorioTime
       if (TimesASeremRemovidos != null){
       	for (Time t: TimesASeremRemovidos){
       		repositorioTime.removerTime(t);
       	}
       }*/
       repositorioTime.removerTime(time);
     } else throw new UsuarioNaoEncontradoException();
   } else {
     throw new IllegalArgumentException();
   }
 }