Currency.java
jmud-0.11/src/Currency.java · 1.4 KB
From the archive jmud-0_11.tgz
Download the archive « Back to the archive contents
import java.io.BufferedWriter;
import java.io.IOException;
import misc.Separators;
class Currency extends Item {
static final int K_GOLD = 0; // a
static final int K_SILVER = 1; // b
static final int K_COPPER = 2; // c
static final String kindLabel[] = {
"ouro",
"prata",
"cobre"
};
static String getKindLabel(int k) {
return (k >= 0 && k < kindLabel.length) ? kindLabel[k] : "desconhecido";
}
static final String kindName[] = {
"peça(s) de ouro",
"peça(s) de prata",
"peça(s) de cobre"
};
static final String kindAbbr[] = {
"PO",
"PP",
"PC"
};
static String getKindAbbr(int k) {
return (k >= 0 && k < kindLabel.length) ? kindAbbr[k] : "(?)";
}
static final int credit[] = {
10000,
1000,
100
};
static final int unitWeight[] = {
100,
100,
100
};
private int kind;
private int value;
Currency(CurrencyProto cp) {
super(cp);
kind = cp.kind;
value = cp.value;
}
protected void finalize() {
super.finalize();
}
int getType() {
return T_CURRENCY;
}
int getKind() {
return kind;
}
/////////////
// Sheetable
public String getSheet() {
return super.getSheet() + Separators.NL + "Tipo: " + getKindLabel(kind) + " Valor: " + value;
}
// Sheetable
/////////////
void save(BufferedWriter writer) throws IOException {
super.save(writer);
writer.write(kind + " " + value); writer.newLine();
}
}