Skip to content

Instantly share code, notes, and snippets.

@bamthomas
Created October 18, 2012 07:36
Show Gist options
  • Save bamthomas/3910307 to your computer and use it in GitHub Desktop.
Save bamthomas/3910307 to your computer and use it in GitHub Desktop.
Bascule
private int calculepalier(StringBuffer buffer, int chiffre, Chiffre chiffreCourant, Chiffre precedent) {
int nombrePalier = chiffre / chiffreCourant.chiffreArabe;
for (int i = 0; i < nombrePalier; i++) {
if (chiffre >= chiffreCourant.chiffreArabe) {
buffer.append(chiffreCourant.name());
chiffre -= chiffreCourant.chiffreArabe;
}
}
if (chiffre == chiffreCourant.chiffreArabe - precedent.chiffreArabe) {
buffer.append(precedent.name());
chiffre += precedent.chiffreArabe;
}
nombrePalier = chiffre / chiffreCourant.chiffreArabe;
for (int i = 0; i < nombrePalier; i++) {
if (chiffre >= chiffreCourant.chiffreArabe) {
buffer.append(chiffreCourant.name());
chiffre -= chiffreCourant.chiffreArabe;
}
}
return chiffre;
}
private int calculepalier(StringBuffer buffer, int chiffre, Chiffre chiffreCourant, Chiffre precedent) {
int nombrePalier = chiffre / chiffreCourant.chiffreArabe;
for (int i = 0; i < nombrePalier; i++) {
buffer.append(chiffreCourant.name());
chiffre -= chiffreCourant.chiffreArabe;
}
if (chiffre == chiffreCourant.chiffreArabe - precedent.chiffreArabe) {
buffer.append(precedent.name());
chiffre += precedent.chiffreArabe;
buffer.append(chiffreCourant.name());
chiffre -= chiffreCourant.chiffreArabe;
}
return chiffre;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment