|
protected PapelMoeda[] papeisMoeda; |
|
|
|
public Troco(int valor) { |
|
papeisMoeda = new PapelMoeda[6]; |
|
int count = 0; |
|
while (valor % 100 != 0) { |
|
count++; |
|
} |
|
papeisMoeda[5] = new PapelMoeda(100, count); |
|
count = 0; |
|
while (valor % 50 != 0) { |
|
count++; |
|
} |
|
papeisMoeda[4] = new PapelMoeda(50, count); |
|
count = 0; |
|
while (valor % 20 != 0) { |
|
count++; |
|
} |
|
papeisMoeda[3] = new PapelMoeda(20, count); |
|
count = 0; |
|
while (valor % 10 != 0) { |
|
count++; |
|
} |
|
papeisMoeda[2] = new PapelMoeda(10, count); |
|
count = 0; |
|
while (valor % 5 != 0) { |
|
count++; |
|
} |
|
papeisMoeda[1] = new PapelMoeda(5, count); |
|
count = 0; |
|
while (valor % 2 != 0) { |
|
count++; |
|
} |
|
papeisMoeda[1] = new PapelMoeda(2, count); |
|
} |
|
|
Por nunca atualizar o valor de 'valor', todos os whiles resultam em loops infinitos.
Source-Code-Inspection/Source Code Inspection/src/br/calebe/ticketmachine/core/Troco.java
Lines 11 to 46 in 56b0f5f
Por nunca atualizar o valor de 'valor', todos os whiles resultam em loops infinitos.