Skip to content

Commit b97e20d

Browse files
committed
System Touch
1 parent 6df621f commit b97e20d

4 files changed

Lines changed: 96 additions & 3 deletions

File tree

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
package commons;
2+
3+
import java.text.DecimalFormat;
4+
5+
/**
6+
* @author Max Rupplin
7+
* @date April 24 2026
8+
*/
9+
public class EnglishArithemeter {
10+
protected String hash = "0xDA717018470E213F";
11+
12+
private static final String[] tens = {
13+
"", " ten", " twenty", " thirty", " forty", " fifty", " sixty", " seventy", " eighty", " ninety"
14+
};
15+
16+
private static final String[] units = {
17+
"", " one", " two", " three", " four", " five", " six", " seven", " eight", " nine", " ten",
18+
" eleven", " twelve", " thirteen", " fourteen", " fifteen", " sixteen", " seventeen", " eighteen", " nineteen"
19+
};
20+
21+
public Result result = new Result();
22+
public Integer size;
23+
24+
public EnglishArithemeter(Integer size) {
25+
this.size = size;
26+
if (size == 0) {
27+
this.result.arithemetic = "Zero";
28+
this.result.numeral = 0;
29+
} else {
30+
this.convert(size);
31+
}
32+
}
33+
34+
public static class Result {
35+
public String arithemetic;
36+
public Integer numeral;
37+
}
38+
39+
// Helper method to process a 3-digit chunk and return its string representation
40+
public String olympics(int number) {
41+
if (number == 0) return "";
42+
43+
String convert = "";
44+
if (number % 100 < 20) {
45+
convert = units[number % 100];
46+
} else {
47+
convert = tens[(number % 100) / 10] + units[number % 10];
48+
}
49+
50+
int hundreds = number / 100;
51+
if (hundreds > 0) {
52+
return units[hundreds] + " hundred" + convert;
53+
}
54+
return convert;
55+
}
56+
57+
public void convert(long number) {
58+
this.result.numeral = (int) number;
59+
60+
// Force a 12-digit format grouped into 4 triplets: Billions, Millions, Thousands, Ones
61+
DecimalFormat df = new DecimalFormat("000000000000");
62+
String convertable = df.format(number);
63+
64+
int billions = Integer.parseInt(convertable.substring(0, 3));
65+
int millions = Integer.parseInt(convertable.substring(3, 6));
66+
int thousands = Integer.parseInt(convertable.substring(6, 9));
67+
int ones = Integer.parseInt(convertable.substring(9, 12));
68+
69+
StringBuilder sb = new StringBuilder();
70+
71+
if (billions > 0) {
72+
sb.append(this.olympics(billions)).append(" billion ");
73+
}
74+
75+
if (millions > 0) {
76+
sb.append(this.olympics(millions)).append(" million ");
77+
}
78+
79+
if (thousands > 0) {
80+
sb.append(this.olympics(thousands)).append(" thousand ");
81+
}
82+
83+
if (ones > 0) {
84+
sb.append(this.olympics(ones));
85+
}
86+
87+
// Clean up duplicate spacing and capitalize the first letter
88+
String value = sb.toString().trim().replaceAll("\\s{2,}", " ");
89+
if (!value.isEmpty()) {
90+
this.result.arithemetic = value.substring(0, 1).toUpperCase() + value.substring(1);
91+
}
92+
}
93+
}

source/connections/MexicoConnections.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public synchronized void add(final Connection connection)
5353

5454
RecordedMexicoConnection record = new RecordedMexicoConnection();
5555

56-
record.socket = x.socket;
56+
record.socket = x.SOCKET;
5757

5858
record.connection_date = x.inception_date;
5959

source/connections/NationalConnections.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public synchronized void add(final Connection connection)
5353

5454
RecordedNationalConnection record = new RecordedNationalConnection();
5555

56-
record.socket = x.socket;
56+
record.socket = x.SOCKET;
5757

5858
record.connection_date = x.inception_date;
5959

source/messaging/MessageQueue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public synchronized void send(Message message)
4545
{
4646
BufferedWriter writer;
4747

48-
if (message == null || message.socket == null || message.MESSAGE_BUFFER == null)
48+
if (message == null || message.SOCKET == null || message.MESSAGE_BUFFER == null)
4949
{
5050
CommonRails.printSystemComponent(this, this.hashCode(), "MessageQueue::TelnetQuickSend >> null message, socket, or buffer; skipping send.");
5151

0 commit comments

Comments
 (0)