public void salvarCondutor(Condutor cond) throws ExcecaoCPFExistente, ExcecaoIdadeImpropriaParaCondutor { Condutor condutor = banco.getCondutorComCpf(cond.getCPF()); if (condutor != null) throw new ExcecaoCPFExistente(); if (ManipuladorData.calculeDiferencaDeAnos(new Date(), cond.getDataNasc()) < 18) throw new ExcecaoIdadeImpropriaParaCondutor(); banco.addCondutor(cond); }
public Object[] monteDadosInf(Infracao inf) { Object[] s = new Object[5]; Condutor cond = banco.getCondutorComCpf(banco.getVeiculoComPlaca(inf.getPlaca()).getCpfDono()); s[0] = (inf.getNumInfracao()); s[1] = FormataPlaca.coloqueMascara(inf.getPlaca()); s[2] = ManipuladorData.format(inf.getDataInf()); s[3] = FormataCPF.formatCpf(cond.getCPF()); s[4] = cond.getNome(); return s; }
public List<Infracao> getInfracoesComNomeCondutor(String nome) { List<Infracao> infs = new LinkedList<Infracao>(getInfracoes()); Condutor cond = null; List<Infracao> infracoes = new LinkedList<Infracao>(); for (Infracao inf : infs) { cond = banco.getCondutorComCpf(banco.getVeiculoComPlaca(inf.getPlaca()).getCpfDono()); if (cond.getNome().toUpperCase().contains(nome.toUpperCase())) infracoes.add(inf); } return infracoes; }
public Map<Long, Integer> getTopInfratores() { List<Infracao> listaInf = new ArrayList<Infracao>(getInfracoes()); Iterator<Infracao> ite = listaInf.iterator(); Map<Long, Integer> infConds = new HashMap<Long, Integer>(); Condutor c; int cont = 0; while (ite.hasNext()) { c = banco.getCondutorComCpf(getVeiculoComPlaca(ite.next().getPlaca()).getCpfDono()); cont = 1; if (infConds.get(c.getCPF()) != null) { cont = (infConds.get(c.getCPF()) + 1); } infConds.put(c.getCPF(), cont); } return MapUtil.ordenePorValor(infConds); }
public Condutor getCondutorComCpf(long cpf) { return banco.getCondutorComCpf(cpf); }