Created
May 24, 2012 01:04
-
-
Save thiagopnts/2778744 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Cliente { | |
private int codigo; | |
private String nome; | |
private float saldo; | |
//construtores e metodos gets e sets | |
} | |
public class TabelaHash { | |
private Cliente[] tabela; | |
public static final int N = 100; | |
float busca(int codigo) { | |
int h = codigo%N; | |
int count = 0; | |
Cliente cli = tabela[h]; | |
while(cli != NULL && count < N) { | |
if(cli.getCodigo() == codigo) { | |
cli.saldo = (cli.saldo * 0.05) + cli.saldo; | |
return cli.saldo; | |
} | |
cli = tabela[++h%N]; | |
count++; | |
} | |
return 0f; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment