freed getal name for calculation code.
This commit is contained in:
parent
0e059dc80a
commit
090985f6fe
|
@ -7,26 +7,26 @@ import love.distributedrebirth.demo4d.base2t.T04PartQuad;
|
|||
import love.distributedrebirth.demo4d.base2t.V018Tord;
|
||||
import love.distributedrebirth.demo4d.base2t.V036Teger;
|
||||
|
||||
public class HebrewGê̄ld {
|
||||
public class Gê̄ldGetậl {
|
||||
|
||||
private final HebrewGetậl nummerAlphabet;
|
||||
private final HebrewGetậl nummerDeelA;
|
||||
private final HebrewGetậl nummerDeelB;
|
||||
private final HebrewGetậl nummerDeelC;
|
||||
private final HebrewDigit nummerAlphabet;
|
||||
private final HebrewDigit nummerDeelA;
|
||||
private final HebrewDigit nummerDeelB;
|
||||
private final HebrewDigit nummerDeelC;
|
||||
private final double totalDecimalValue;
|
||||
private static final Character LEFT_TO_RIGHT_MARK = 0x200E;
|
||||
private static final Character RIGHT_TO_LEFT_MARK = 0x200F;
|
||||
|
||||
public HebrewGê̄ld(V036Teger teger) {
|
||||
public Gê̄ldGetậl(V036Teger teger) {
|
||||
this(
|
||||
new HebrewGetậl(teger.getTytePart(T04PartQuad.PART_1)),
|
||||
new HebrewGetậl(teger.getTytePart(T04PartQuad.PART_2)),
|
||||
new HebrewGetậl(teger.getTytePart(T04PartQuad.PART_3)),
|
||||
new HebrewGetậl(teger.getTytePart(T04PartQuad.PART_4))
|
||||
new HebrewDigit(teger.getTytePart(T04PartQuad.PART_1)),
|
||||
new HebrewDigit(teger.getTytePart(T04PartQuad.PART_2)),
|
||||
new HebrewDigit(teger.getTytePart(T04PartQuad.PART_3)),
|
||||
new HebrewDigit(teger.getTytePart(T04PartQuad.PART_4))
|
||||
);
|
||||
}
|
||||
|
||||
public HebrewGê̄ld(HebrewGetậl nummerAlphabet, HebrewGetậl nummerDeelA, HebrewGetậl nummerDeelB, HebrewGetậl nummerDeelC) {
|
||||
public Gê̄ldGetậl(HebrewDigit nummerAlphabet, HebrewDigit nummerDeelA, HebrewDigit nummerDeelB, HebrewDigit nummerDeelC) {
|
||||
this.nummerAlphabet = nummerAlphabet;
|
||||
this.nummerDeelA = nummerDeelA;
|
||||
this.nummerDeelB = nummerDeelB;
|
||||
|
@ -34,7 +34,7 @@ public class HebrewGê̄ld {
|
|||
this.totalDecimalValue = calculateDecimalValue();
|
||||
}
|
||||
|
||||
public HebrewGê̄ld(String money) {
|
||||
public Gê̄ldGetậl(String money) {
|
||||
if (money == null) {
|
||||
throw new NullPointerException("Can't parse null money");
|
||||
}
|
||||
|
@ -44,9 +44,9 @@ public class HebrewGê̄ld {
|
|||
if (money.length() > 8) { // RL + 4 chars + 3 vowels
|
||||
throw new IllegalArgumentException("Money length should not exceed 8 codepoints");
|
||||
}
|
||||
List<HebrewGetậl> result = new ArrayList<>();
|
||||
List<HebrewDigit> result = new ArrayList<>();
|
||||
|
||||
HebrewGetậl geldDigit = null;
|
||||
HebrewDigit geldDigit = null;
|
||||
for (int i=0;i<money.length();i++) {
|
||||
char codePoint = (char) money.codePointAt(i);
|
||||
if (LEFT_TO_RIGHT_MARK.equals(codePoint)) {
|
||||
|
@ -56,8 +56,8 @@ public class HebrewGê̄ld {
|
|||
continue;
|
||||
}
|
||||
if (geldDigit != null) {
|
||||
HebrewGetậlVowel vowel = HebrewGetậlVowel.valueOf(codePoint);
|
||||
if (!HebrewGetậlVowel.NONE.equals(vowel)) {
|
||||
HebrewDigitVowel vowel = HebrewDigitVowel.valueOf(codePoint);
|
||||
if (!HebrewDigitVowel.NONE.equals(vowel)) {
|
||||
geldDigit.setVowel(vowel);
|
||||
result.add(geldDigit);
|
||||
geldDigit = null;
|
||||
|
@ -66,11 +66,11 @@ public class HebrewGê̄ld {
|
|||
result.add(geldDigit);
|
||||
}
|
||||
}
|
||||
HebrewGetậlLetter letter = HebrewGetậlLetter.valueOf(codePoint);
|
||||
if (HebrewGetậlLetter.NONE.equals(letter)) {
|
||||
HebrewDigitLetter letter = HebrewDigitLetter.valueOf(codePoint);
|
||||
if (HebrewDigitLetter.NONE.equals(letter)) {
|
||||
throw new IllegalArgumentException("Unknown fraction codepoint: 0x"+Integer.toHexString(codePoint));
|
||||
}
|
||||
geldDigit = new HebrewGetậl(letter);
|
||||
geldDigit = new HebrewDigit(letter);
|
||||
}
|
||||
if (geldDigit != null) {
|
||||
result.add(geldDigit);
|
||||
|
@ -79,24 +79,24 @@ public class HebrewGê̄ld {
|
|||
if (result.isEmpty()) {
|
||||
throw new IllegalArgumentException("No hebrew money found");
|
||||
}
|
||||
HebrewGetậl full = result.get(0);
|
||||
HebrewGetậl deelA = null;
|
||||
HebrewGetậl deelB = null;
|
||||
HebrewGetậl deelC = null;
|
||||
HebrewDigit full = result.get(0);
|
||||
HebrewDigit deelA = null;
|
||||
HebrewDigit deelB = null;
|
||||
HebrewDigit deelC = null;
|
||||
if (result.size() > 1) {
|
||||
deelA = result.get(1);
|
||||
} else {
|
||||
deelA = new HebrewGetậl();
|
||||
deelA = new HebrewDigit();
|
||||
}
|
||||
if (result.size() > 2) {
|
||||
deelB = result.get(2);
|
||||
} else {
|
||||
deelB = new HebrewGetậl();
|
||||
deelB = new HebrewDigit();
|
||||
}
|
||||
if (result.size() > 3) {
|
||||
deelC = result.get(3);
|
||||
} else {
|
||||
deelC = new HebrewGetậl();
|
||||
deelC = new HebrewDigit();
|
||||
}
|
||||
this.nummerAlphabet = full;
|
||||
this.nummerDeelA = deelA;
|
||||
|
@ -107,35 +107,35 @@ public class HebrewGê̄ld {
|
|||
|
||||
private double calculateDecimalValue() {
|
||||
boolean hasFourDigits =
|
||||
!HebrewGetậlLetter.NONE.equals(nummerDeelA.getLetter()) &&
|
||||
!HebrewGetậlLetter.NONE.equals(nummerDeelB.getLetter()) &&
|
||||
!HebrewGetậlLetter.NONE.equals(nummerDeelC.getLetter());
|
||||
!HebrewDigitLetter.NONE.equals(nummerDeelA.getLetter()) &&
|
||||
!HebrewDigitLetter.NONE.equals(nummerDeelB.getLetter()) &&
|
||||
!HebrewDigitLetter.NONE.equals(nummerDeelC.getLetter());
|
||||
double totalDecimalValue = nummerAlphabet.toDecimalValue(hasFourDigits);
|
||||
if (!HebrewGetậlLetter.NONE.equals(nummerDeelA.getLetter())) {
|
||||
if (!HebrewDigitLetter.NONE.equals(nummerDeelA.getLetter())) {
|
||||
totalDecimalValue += nummerDeelA.toDecimalValue(false);
|
||||
}
|
||||
if (!HebrewGetậlLetter.NONE.equals(nummerDeelB.getLetter())) {
|
||||
if (!HebrewDigitLetter.NONE.equals(nummerDeelB.getLetter())) {
|
||||
totalDecimalValue += nummerDeelB.toDecimalValue(false);
|
||||
}
|
||||
if (!HebrewGetậlLetter.NONE.equals(nummerDeelC.getLetter())) {
|
||||
if (!HebrewDigitLetter.NONE.equals(nummerDeelC.getLetter())) {
|
||||
totalDecimalValue += nummerDeelC.toDecimalValue(false);
|
||||
}
|
||||
return totalDecimalValue;
|
||||
}
|
||||
|
||||
public HebrewGetậl getNummerAlphabet() {
|
||||
public HebrewDigit getNummerAlphabet() {
|
||||
return nummerAlphabet;
|
||||
}
|
||||
|
||||
public HebrewGetậl getNummerDeelA() {
|
||||
public HebrewDigit getNummerDeelA() {
|
||||
return nummerDeelA;
|
||||
}
|
||||
|
||||
public HebrewGetậl getNummerDeelB() {
|
||||
public HebrewDigit getNummerDeelB() {
|
||||
return nummerDeelB;
|
||||
}
|
||||
|
||||
public HebrewGetậl getNummerDeelC() {
|
||||
public HebrewDigit getNummerDeelC() {
|
||||
return nummerDeelC;
|
||||
}
|
||||
|
||||
|
@ -158,24 +158,24 @@ public class HebrewGê̄ld {
|
|||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(RIGHT_TO_LEFT_MARK);
|
||||
buf.append(nummerAlphabet.getLetter().getCharacter());
|
||||
if (!HebrewGetậlVowel.NONE.equals(nummerAlphabet.getVowel())) {
|
||||
if (!HebrewDigitVowel.NONE.equals(nummerAlphabet.getVowel())) {
|
||||
buf.append(nummerAlphabet.getVowel().getCharacter());
|
||||
}
|
||||
if (!HebrewGetậlLetter.NONE.equals(nummerDeelA.getLetter())) {
|
||||
if (!HebrewDigitLetter.NONE.equals(nummerDeelA.getLetter())) {
|
||||
buf.append(nummerDeelA.getLetter().getCharacter());
|
||||
if (!HebrewGetậlVowel.NONE.equals(nummerDeelA.getVowel())) {
|
||||
if (!HebrewDigitVowel.NONE.equals(nummerDeelA.getVowel())) {
|
||||
buf.append(nummerDeelA.getVowel().getCharacter());
|
||||
}
|
||||
}
|
||||
if (!HebrewGetậlLetter.NONE.equals(nummerDeelB.getLetter())) {
|
||||
if (!HebrewDigitLetter.NONE.equals(nummerDeelB.getLetter())) {
|
||||
buf.append(nummerDeelB.getLetter().getCharacter());
|
||||
if (!HebrewGetậlVowel.NONE.equals(nummerDeelB.getVowel())) {
|
||||
if (!HebrewDigitVowel.NONE.equals(nummerDeelB.getVowel())) {
|
||||
buf.append(nummerDeelB.getVowel().getCharacter());
|
||||
}
|
||||
}
|
||||
if (!HebrewGetậlLetter.NONE.equals(nummerDeelC.getLetter())) {
|
||||
if (!HebrewDigitLetter.NONE.equals(nummerDeelC.getLetter())) {
|
||||
buf.append(nummerDeelC.getLetter().getCharacter());
|
||||
if (!HebrewGetậlVowel.NONE.equals(nummerDeelC.getVowel())) {
|
||||
if (!HebrewDigitVowel.NONE.equals(nummerDeelC.getVowel())) {
|
||||
buf.append(nummerDeelC.getVowel().getCharacter());
|
||||
}
|
||||
}
|
|
@ -4,34 +4,34 @@ import love.distributedrebirth.demo4d.base2t.T03PartTrit;
|
|||
import love.distributedrebirth.demo4d.base2t.T08PartOctal;
|
||||
import love.distributedrebirth.demo4d.base2t.V009Tyte;
|
||||
|
||||
public class HebrewGetậl {
|
||||
public class HebrewDigit {
|
||||
|
||||
private static final double NUMERATOR_ONE = 1d;
|
||||
private static final int FRACTION_POWER = 10;
|
||||
private HebrewGetậlLetter letter;
|
||||
private HebrewGetậlVowel vowel;
|
||||
private HebrewDigitLetter letter;
|
||||
private HebrewDigitVowel vowel;
|
||||
|
||||
public HebrewGetậl() {
|
||||
this.letter = HebrewGetậlLetter.NONE;
|
||||
this.vowel = HebrewGetậlVowel.NONE;
|
||||
public HebrewDigit() {
|
||||
this.letter = HebrewDigitLetter.NONE;
|
||||
this.vowel = HebrewDigitVowel.NONE;
|
||||
}
|
||||
|
||||
public HebrewGetậl(HebrewGetậlLetter letter) {
|
||||
public HebrewDigit(HebrewDigitLetter letter) {
|
||||
this.letter = letter;
|
||||
this.vowel = HebrewGetậlVowel.NONE;
|
||||
this.vowel = HebrewDigitVowel.NONE;
|
||||
}
|
||||
|
||||
public HebrewGetậl(V009Tyte tyte) {
|
||||
public HebrewDigit(V009Tyte tyte) {
|
||||
int value0 = tyte.getValue(T03PartTrit.PART_1).getValue().ordinalOf(T08PartOctal.PART_1);
|
||||
int value1 = tyte.getValue(T03PartTrit.PART_2).getValue().ordinalOf(T08PartOctal.PART_2);
|
||||
int value2 = tyte.getValue(T03PartTrit.PART_3).getValue().ordinalOf(T08PartOctal.PART_3);
|
||||
int combinedValue = value0 + value1 + value2;
|
||||
letter = HebrewGetậlLetter.indexOf(combinedValue);
|
||||
vowel = HebrewGetậlVowel.indexOf(combinedValue >> HebrewGetậlLetter.SHIFT_5);
|
||||
letter = HebrewDigitLetter.indexOf(combinedValue);
|
||||
vowel = HebrewDigitVowel.indexOf(combinedValue >> HebrewDigitLetter.SHIFT_5);
|
||||
}
|
||||
|
||||
public V009Tyte toTyte() {
|
||||
int combinedValue = letter.ordinal() + (vowel.ordinal() << HebrewGetậlLetter.SHIFT_5);
|
||||
int combinedValue = letter.ordinal() + (vowel.ordinal() << HebrewDigitLetter.SHIFT_5);
|
||||
T08PartOctal value0 = T08PartOctal.indexOf(T08PartOctal.PART_1, combinedValue);
|
||||
T08PartOctal value1 = T08PartOctal.indexOf(T08PartOctal.PART_2, combinedValue);
|
||||
T08PartOctal value2 = T08PartOctal.indexOf(T08PartOctal.PART_3, combinedValue);
|
||||
|
@ -43,26 +43,26 @@ public class HebrewGetậl {
|
|||
if (firstChar) {
|
||||
return fraction; // use full value
|
||||
}
|
||||
if (!HebrewGetậlVowel.NONE.equals(vowel)) {
|
||||
if (!HebrewDigitVowel.NONE.equals(vowel)) {
|
||||
fraction = fraction * Math.pow(FRACTION_POWER, vowel.getFractionOffset());
|
||||
}
|
||||
double result = NUMERATOR_ONE/fraction;
|
||||
return result;
|
||||
}
|
||||
|
||||
public HebrewGetậlLetter getLetter() {
|
||||
public HebrewDigitLetter getLetter() {
|
||||
return letter;
|
||||
}
|
||||
|
||||
public void setLetter(HebrewGetậlLetter letter) {
|
||||
public void setLetter(HebrewDigitLetter letter) {
|
||||
this.letter = letter;
|
||||
}
|
||||
|
||||
public HebrewGetậlVowel getVowel() {
|
||||
public HebrewDigitVowel getVowel() {
|
||||
return vowel;
|
||||
}
|
||||
|
||||
public void setVowel(HebrewGetậlVowel vowel) {
|
||||
public void setVowel(HebrewDigitVowel vowel) {
|
||||
this.vowel = vowel;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package love.distributedrebirth.demo4d.fraction4d;
|
||||
|
||||
public enum HebrewGetậlLetter {
|
||||
public enum HebrewDigitLetter {
|
||||
// Unicode is horror in any language else than ascii;
|
||||
// VS Alphabet order
|
||||
// VS Unicode order
|
||||
|
@ -70,7 +70,7 @@ public enum HebrewGetậlLetter {
|
|||
private final int decimal;
|
||||
private final char character;
|
||||
|
||||
private HebrewGetậlLetter(int decimal, char character) {
|
||||
private HebrewDigitLetter(int decimal, char character) {
|
||||
this.decimal = decimal;
|
||||
this.character = character;
|
||||
}
|
||||
|
@ -83,16 +83,16 @@ public enum HebrewGetậlLetter {
|
|||
return character;
|
||||
}
|
||||
|
||||
public static HebrewGetậlLetter indexOf(int index) {
|
||||
public static HebrewDigitLetter indexOf(int index) {
|
||||
return values()[index & BITMASK];
|
||||
}
|
||||
|
||||
public static HebrewGetậlLetter valueOf(char codePoint) {
|
||||
for (HebrewGetậlLetter vowel:values()) {
|
||||
public static HebrewDigitLetter valueOf(char codePoint) {
|
||||
for (HebrewDigitLetter vowel:values()) {
|
||||
if (vowel.getCharacter() == codePoint) {
|
||||
return vowel;
|
||||
}
|
||||
}
|
||||
return HebrewGetậlLetter.NONE;
|
||||
return HebrewDigitLetter.NONE;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package love.distributedrebirth.demo4d.fraction4d;
|
||||
|
||||
public enum HebrewGetậlVowel {
|
||||
public enum HebrewDigitVowel {
|
||||
NONE (0, (char) 0x0000),
|
||||
VOWEL_1 (1, (char) 0x05B4),
|
||||
VOWEL_2 (2, (char) 0x05B5),
|
||||
|
@ -23,7 +23,7 @@ public enum HebrewGetậlVowel {
|
|||
private final int fractionOffset;
|
||||
private final char character;
|
||||
|
||||
private HebrewGetậlVowel(int fractionOffset, char character) {
|
||||
private HebrewDigitVowel(int fractionOffset, char character) {
|
||||
this.fractionOffset = fractionOffset;
|
||||
this.character = character;
|
||||
}
|
||||
|
@ -36,16 +36,16 @@ public enum HebrewGetậlVowel {
|
|||
return character;
|
||||
}
|
||||
|
||||
public static HebrewGetậlVowel indexOf(int index) {
|
||||
public static HebrewDigitVowel indexOf(int index) {
|
||||
return values()[index & BITMASK];
|
||||
}
|
||||
|
||||
public static HebrewGetậlVowel valueOf(char codePoint) {
|
||||
for (HebrewGetậlVowel vowel:values()) {
|
||||
public static HebrewDigitVowel valueOf(char codePoint) {
|
||||
for (HebrewDigitVowel vowel:values()) {
|
||||
if (vowel.getCharacter() == codePoint) {
|
||||
return vowel;
|
||||
}
|
||||
}
|
||||
return HebrewGetậlVowel.NONE;
|
||||
return HebrewDigitVowel.NONE;
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import imgui.flag.ImGuiTableFlags;
|
|||
import imgui.type.ImBoolean;
|
||||
import love.distributedrebirth.demo4d.Demo4DMain;
|
||||
import love.distributedrebirth.demo4d.ImGuiRendererMain;
|
||||
import love.distributedrebirth.demo4d.fraction4d.HebrewGê̄ld;
|
||||
import love.distributedrebirth.demo4d.fraction4d.Gê̄ldGetậl;
|
||||
|
||||
public class HebrewWalletRenderer extends ImGuiRendererMain {
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class HebrewWalletRenderer extends ImGuiRendererMain {
|
|||
"הזפץ","מספר","צצצצ","ץאאא","דואר"
|
||||
};
|
||||
for (String data:walletData) {
|
||||
HebrewGê̄ld geld = new HebrewGê̄ld(data);
|
||||
Gê̄ldGetậl geld = new Gê̄ldGetậl(data);
|
||||
ImGui.tableNextRow();
|
||||
ImGui.tableNextColumn();
|
||||
ImGui.text(data.length()==2||data.length()==3?"OUT":"IN");
|
||||
|
|
Loading…
Reference in a new issue