import java.util.* ;
import java.io.* ;
class Ideone {
public static void main
( String [ ] args
) { ArrayList< Candidato> Candidatos = new ArrayList< Candidato> ( ) ;
Scanner e
= new Scanner
( System .
in ) ; int op;
do {
System .
out .
println ( "Cadastrar 1 " ) ; System .
out .
println ( "Consultar 2" ) ; System .
out .
println ( "Votar 3" ) ; System .
out .
println ( "Finalizar 4" ) ; op = e .nextInt ( ) ;
if ( op == 1 ) {
System .
out .
println ( "digite o numero" ) ; System .
out .
println ( "digite o nome " ) ; System .
out .
println ( "digite o partido" ) ; Candidatos.add ( new Candidato( numero, nome, partido) ) ;
} else if ( op == 2 ) {
System .
out .
println ( "Digite um numero" ) ; for ( int i = 0 ; i < Candidatos.size ( ) ; i++ ) {
if ( Candidatos.get ( i) .getNumero ( ) .equals ( n) ) {
System .
out .
println ( Candidatos.
get ( i
) .
getNome ( ) + ", " + Candidatos.
get ( i
) .
getPartido ( ) + ", " + Candidatos.
get ( i
) .
getVotos ( ) ) ; }
}
} else if ( op == 3 ) {
System .
out .
println ( "Digite um numero de quem deseja votar" ) ; int i = 0 ;
for ( ; i < Candidatos.size ( ) ; i++ ) {
if ( Candidatos.get ( i) .getNumero ( ) .equals ( n) ) {
break ;
}
}
if ( i != Candidatos.size ( ) ) Candidatos.get ( i) .Votar ( ) ;
}
} while ( op != 4 ) ;
}
}
class Candidato {
int votos = 0 ;
this .numero = numero;
this .nome = nome;
this .partido = partido;
}
public void Votar( ) { votos++; }
public int getVotos( ) { return votos; }
public String getNumero
( ) { return numero
; } public String getNome
( ) { return nome
; } public String getPartido
( ) { return partido
; } }
//https://pt.stackoverflow.com/q/241092/101
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5pby4qOwoKY2xhc3MgSWRlb25lIHsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKQl7CgkJQXJyYXlMaXN0PENhbmRpZGF0bz4gQ2FuZGlkYXRvcyA9IG5ldyBBcnJheUxpc3Q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CSAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oQ2FuZGlkYXRvcy5nZXQoaSkuZ2V0Tm9tZSgpICsgIiwgIiArIENhbmRpZGF0b3MuZ2V0KGkpLmdldFBhcnRpZG8oKSArICIsICIgKyBDYW5kaWRhdG9zLmdldChpKS5nZXRWb3RvcygpKTsKCQkgICAgICAgICAgICB9CgkJICAgICAgICB9CgkJICAgIH0gZWxzZSBpZiAob3AgPT0gMykgewoJCSAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJEaWdpdGUgdW0gbnVtZXJvIGRlIHF1ZW0gZGVzZWphIHZvdGFyIik7CgkJICAgICAgICBTdHJpbmcgbiA9IGUubmV4dCgpOwoJCSAgICAgICAgaW50IGkgPSAwOwogICAJCSAgICAgICAgZm9yICg7IGkgPCBDYW5kaWRhdG9zLnNpemUoKTsgaSsrKSB7CgkJICAgICAgICAgICAgaWYgKENhbmRpZGF0b3MuZ2V0KGkpLmdldE51bWVybygpLmVxdWFscyhuKSkgewoJCSAgICAgICAgICAgICAgICBicmVhazsKCQkgICAgICAgICAgICB9CiAgIAkJICAgICAgICB9CiAgIAkJICAgICAgICBpZiAoaSAhPSBDYW5kaWRhdG9zLnNpemUoKSkgQ2FuZGlkYXRvcy5nZXQoaSkuVm90YXIoKTsKCQkgICAgfQoJCX0gd2hpbGUgKG9wICE9NCApOwoJfQp9CgpjbGFzcyBDYW5kaWRhdG8gewogICAgU3RyaW5nIG5vbWU7CiAgICBTdHJpbmcgcGFydGlkbzsKICAgIFN0cmluZyBudW1lcm87CiAgICBpbnQgdm90b3MgPSAwOwogICAgcHVibGljIENhbmRpZGF0byhTdHJpbmcgbnVtZXJvLCBTdHJpbmcgbm9tZSwgU3RyaW5nIHBhcnRpZG8pIHsKICAgIAl0aGlzLm51bWVybyA9IG51bWVybzsKICAgIAl0aGlzLm5vbWUgPSBub21lOwogICAgCXRoaXMucGFydGlkbyA9IHBhcnRpZG87CiAgICB9CiAgICBwdWJsaWMgdm9pZCBWb3RhcigpIHsgdm90b3MrKzsgfQogICAgcHVibGljIGludCBnZXRWb3RvcygpIHsgcmV0dXJuIHZvdG9zOyB9CiAgICBwdWJsaWMgU3RyaW5nIGdldE51bWVybygpIHsgcmV0dXJuIG51bWVybzsgfQogICAgcHVibGljIFN0cmluZyBnZXROb21lKCkgeyByZXR1cm4gbm9tZTsgfQogICAgcHVibGljIFN0cmluZyBnZXRQYXJ0aWRvKCkgeyByZXR1cm4gcGFydGlkbzsgfQp9CgovL2h0dHBzOi8vcHQuc3RhY2tvdmVyZmxvdy5jb20vcS8yNDEwOTIvMTAx