Skip to content

Commit bb8f286

Browse files
committed
finished truthTable output
1 parent 91edb65 commit bb8f286

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

btc-ascii-table-1.0.jar

16.1 KB
Binary file not shown.

src/Editor.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
import java.io.FileWriter;
1010
import java.io.Reader;
1111
import java.io.IOException;
12+
import java.util.ArrayList;
1213
import java.util.LinkedList;
1314

15+
import com.bethecoder.ascii_table.ASCIITable;
16+
import com.bethecoder.ascii_table.ASCIITableHeader;
17+
1418
class Editor
1519
{
1620
LinkedList<Chip> chipList;
@@ -97,6 +101,7 @@ public void saveChipToFile(Chip c) {
97101
connection.put("to", to);
98102

99103
connections.add(connection);
104+
100105
}
101106
}
102107

@@ -331,6 +336,26 @@ public void printTruthTable(Chip c) {
331336
truthTable[i][c.iPins.size() + j] = c.oPins.get(j).activated;
332337
}
333338
}
339+
340+
String[][] truthTableString = new String[totalCombinations][c.iPins.size() + c.oPins.size()];
341+
342+
for(int i = 0; i < truthTable.length;i++) {
343+
for(int j = 0; j < truthTable[i].length; j++) {
344+
truthTableString[i][j] = Boolean.toString(truthTable[i][j]);
345+
}
346+
}
347+
348+
ASCIITableHeader[] header = new ASCIITableHeader[c.iPins.size() + c.oPins.size()];
349+
350+
ArrayList<Pin> both = new ArrayList<>();
351+
both.addAll(c.iPins);
352+
both.addAll(c.oPins);
353+
354+
for(int i = 0; i < both.size(); i++) {
355+
header[i] = new ASCIITableHeader(both.get(i).name, ASCIITable.ALIGN_LEFT);
356+
}
357+
358+
ASCIITable.getInstance().printTable(header, truthTableString);
334359
}
335360

336361
public void pinOut(Chip c) {

0 commit comments

Comments
 (0)