Added base10 and base11

This commit is contained in:
Willem Cazander 2022-02-01 12:12:06 +01:00
parent 69fc75b1af
commit ed938585df
8 changed files with 214 additions and 7 deletions

View file

@ -51,7 +51,8 @@ public class BasePartRenderer extends ImGuiRendererMain {
BasePart[] baseParts = BasePartFactory.buildBasePartsByBase(baseNumber); BasePart[] baseParts = BasePartFactory.buildBasePartsByBase(baseNumber);
int flags = ImGuiTableFlags.ScrollX | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.BordersV; int flags = ImGuiTableFlags.ScrollX | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.BordersV;
ImGui.beginTable("base-part", 9, flags); ImGui.beginTable("base-part", 10, flags);
ImGui.tableSetupColumn("Name");
ImGui.tableSetupColumn("Ordinal"); ImGui.tableSetupColumn("Ordinal");
ImGui.tableSetupColumn("Tone"); ImGui.tableSetupColumn("Tone");
ImGui.tableSetupColumn("Letter"); ImGui.tableSetupColumn("Letter");
@ -66,6 +67,8 @@ public class BasePartRenderer extends ImGuiRendererMain {
for (BasePart part:baseParts) { for (BasePart part:baseParts) {
ImGui.tableNextRow(); ImGui.tableNextRow();
ImGui.tableNextColumn(); ImGui.tableNextColumn();
ImGui.text(part.name());
ImGui.tableNextColumn();
ImGui.text(Integer.toString(part.ordinal())); ImGui.text(Integer.toString(part.ordinal()));
ImGui.tableNextColumn(); ImGui.tableNextColumn();
ImGui.text(part.getIdentifierTone()); ImGui.text(part.getIdentifierTone());

View file

@ -4,7 +4,7 @@ import love.distributedrebirth.numberxd.base2t.facet.BasePart;
public final class BasePartFactory { public final class BasePartFactory {
private static final int[] SUPPORTED_BASES = {2,3,4,5,6,7,8,12,16,20,60}; private static final int[] SUPPORTED_BASES = {2,3,4,5,6,7,8,10,11,12,16,20,60};
public static int[] getSupportedBases() { public static int[] getSupportedBases() {
return SUPPORTED_BASES; return SUPPORTED_BASES;
@ -29,9 +29,9 @@ public final class BasePartFactory {
case 9: case 9:
throw new IllegalArgumentException("Unsupported base: "+base); throw new IllegalArgumentException("Unsupported base: "+base);
case 10: case 10:
throw new IllegalArgumentException("Unsupported base: "+base); return T10PartDecimal.values();
case 11: case 11:
throw new IllegalArgumentException("Unsupported base: "+base); return T11PartUndecimal.values();
case 12: case 12:
return T12PartUncial.values(); return T12PartUncial.values();
case 16: case 16:

View file

@ -0,0 +1,64 @@
package love.distributedrebirth.numberxd.base2t;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import love.distributedrebirth.numberxd.base2t.facet.BasePart;
import love.distributedrebirth.numberxd.base2t.facet.BaseFacetKey;
import love.distributedrebirth.numberxd.base2t.facet.BaseFacetMap;
/**
* The distribution by 10.
*
* @author willemtsade ©Δ 仙上主天
*/
public enum T10PartDecimal implements BasePart {
PART_1 ("˥","0","","zero"),
PART_2 ("˦","1","","one"),
PART_3 ("˧","2","","two"),
PART_4 ("˨","3","","three"),
PART_5 ("˩","4","","four"),
PART_6 ("","5","","five"),
PART_7 ("","6","","six"),
PART_8 ("","7","","seven"),
PART_9 ("","8","","eight"),
PART_10("","9","","nine"),
;
public static int LENGTH() { return values().length; };
private final BaseFacetMap bfm = BaseFacetMap.newInstance();
private static final Map<String, T10PartDecimal> TONE_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v)));
private static final Map<String, T10PartDecimal> CHINA_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v)));
private T10PartDecimal(String idTone, String idLetter, String chinaKey, String chinaValue) {
this.getBFM().putInit(BaseFacetKey.ID_TONE, idTone);
this.getBFM().putInit(BaseFacetKey.ID_LETTER, idLetter);
this.getBFM().putInit(BaseFacetKey.CHINA_KEY, chinaKey);
this.getBFM().putInit(BaseFacetKey.CHINA_VALUE, chinaValue);
}
@Override
public BaseFacetMap getBFM() {
return bfm;
}
public static void forEach(Consumer<T10PartDecimal> consumer) {
for (T10PartDecimal value:values()) {
consumer.accept(value);
}
}
public static T10PartDecimal valueOfTone(String identifierTone) {
return TONE_MAP.get(identifierTone);
}
public static T10PartDecimal valueOfChina(String chinaKey) {
return CHINA_MAP.get(chinaKey);
}
}

View file

@ -0,0 +1,65 @@
package love.distributedrebirth.numberxd.base2t;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import love.distributedrebirth.numberxd.base2t.facet.BasePart;
import love.distributedrebirth.numberxd.base2t.facet.BaseFacetKey;
import love.distributedrebirth.numberxd.base2t.facet.BaseFacetMap;
/**
* The distribution by 11.
*
* @author willemtsade ©Δ 仙上主天
*/
public enum T11PartUndecimal implements BasePart {
PART_1 ("˥","0","","walk"),
PART_2 ("","1","","run"),
PART_3 ("","2","","sit"),
PART_4 ("","3","","hang"),
PART_5 ("","4","","lay"),
PART_6 ("","5","","jump"),
PART_7 ("","6","","drop"),
PART_8 ("","7","","lonely"),
PART_9 ("","8","","talk"),
PART_10("","9","","life"),
PART_11("˩","=","","mate"),
;
public static int LENGTH() { return values().length; };
private final BaseFacetMap bfm = BaseFacetMap.newInstance();
private static final Map<String, T11PartUndecimal> TONE_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v)));
private static final Map<String, T11PartUndecimal> CHINA_MAP = Collections.unmodifiableMap(
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v)));
private T11PartUndecimal(String idTone, String idLetter, String chinaKey, String chinaValue) {
this.getBFM().putInit(BaseFacetKey.ID_TONE, idTone);
this.getBFM().putInit(BaseFacetKey.ID_LETTER, idLetter);
this.getBFM().putInit(BaseFacetKey.CHINA_KEY, chinaKey);
this.getBFM().putInit(BaseFacetKey.CHINA_VALUE, chinaValue);
}
@Override
public BaseFacetMap getBFM() {
return bfm;
}
public static void forEach(Consumer<T11PartUndecimal> consumer) {
for (T11PartUndecimal value:values()) {
consumer.accept(value);
}
}
public static T11PartUndecimal valueOfTone(String identifierTone) {
return TONE_MAP.get(identifierTone);
}
public static T11PartUndecimal valueOfChina(String chinaKey) {
return CHINA_MAP.get(chinaKey);
}
}

View file

@ -7,6 +7,8 @@ package love.distributedrebirth.numberxd.base2t.facet;
*/ */
public interface BasePart extends BaseFacetStore { public interface BasePart extends BaseFacetStore {
String name();
int ordinal(); int ordinal();
default String getIdentifierTone() { default String getIdentifierTone() {

View file

@ -21,9 +21,6 @@ public class BasePartFactoryTest {
Assertions.assertNotNull(bases); Assertions.assertNotNull(bases);
Assertions.assertTrue(bases.length > 1); Assertions.assertTrue(bases.length > 1);
Assertions.assertTrue(bases.length < 100); Assertions.assertTrue(bases.length < 100);
for (int base:bases) {
Assertions.assertNotNull(base);
}
} }
@Test @Test

View file

@ -0,0 +1,38 @@
package love.distributedrebirth.numberxd.base2t;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
*
*
* @author willemtsade ©Δ 仙上主天
*/
public class T10PartDecimalTest {
@Test
public void testBasePart() {
for (T10PartDecimal value:T10PartDecimal.values()) {
Assertions.assertNotNull(value.getIdentifierTone());
Assertions.assertNotNull(value.getIdentifierLetter());
Assertions.assertNotNull(value.getChinaKey());
Assertions.assertNotNull(value.getChinaValue());
}
}
@Test
public void testToneMap() {
Assertions.assertEquals(T10PartDecimal.PART_1, T10PartDecimal.valueOfTone("˥"));
Assertions.assertEquals(T10PartDecimal.PART_2, T10PartDecimal.valueOfTone("˦"));
Assertions.assertEquals(T10PartDecimal.PART_9, T10PartDecimal.valueOfTone(""));
Assertions.assertEquals(T10PartDecimal.PART_10, T10PartDecimal.valueOfTone(""));
}
@Test
public void testChinaMap() {
Assertions.assertEquals(T10PartDecimal.PART_1, T10PartDecimal.valueOfChina(""));
Assertions.assertEquals(T10PartDecimal.PART_2, T10PartDecimal.valueOfChina(""));
Assertions.assertEquals(T10PartDecimal.PART_9, T10PartDecimal.valueOfChina(""));
Assertions.assertEquals(T10PartDecimal.PART_10, T10PartDecimal.valueOfChina(""));
}
}

View file

@ -0,0 +1,38 @@
package love.distributedrebirth.numberxd.base2t;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
*
*
* @author willemtsade ©Δ 仙上主天
*/
public class T11PartUndecimalTest {
@Test
public void testBasePart() {
for (T11PartUndecimal value:T11PartUndecimal.values()) {
Assertions.assertNotNull(value.getIdentifierTone());
Assertions.assertNotNull(value.getIdentifierLetter());
Assertions.assertNotNull(value.getChinaKey());
Assertions.assertNotNull(value.getChinaValue());
}
}
@Test
public void testToneMap() {
Assertions.assertEquals(T11PartUndecimal.PART_1, T11PartUndecimal.valueOfTone("˥"));
Assertions.assertEquals(T11PartUndecimal.PART_2, T11PartUndecimal.valueOfTone(""));
Assertions.assertEquals(T11PartUndecimal.PART_10, T11PartUndecimal.valueOfTone(""));
Assertions.assertEquals(T11PartUndecimal.PART_11, T11PartUndecimal.valueOfTone("˩"));
}
@Test
public void testChinaMap() {
Assertions.assertEquals(T11PartUndecimal.PART_1, T11PartUndecimal.valueOfChina(""));
Assertions.assertEquals(T11PartUndecimal.PART_2, T11PartUndecimal.valueOfChina(""));
Assertions.assertEquals(T11PartUndecimal.PART_10, T11PartUndecimal.valueOfChina(""));
Assertions.assertEquals(T11PartUndecimal.PART_11, T11PartUndecimal.valueOfChina(""));
}
}