|
9 | 9 | import java.io.FileWriter; |
10 | 10 | import java.io.Reader; |
11 | 11 | import java.io.IOException; |
| 12 | +import java.util.ArrayList; |
12 | 13 | import java.util.LinkedList; |
13 | 14 |
|
| 15 | +import com.bethecoder.ascii_table.ASCIITable; |
| 16 | +import com.bethecoder.ascii_table.ASCIITableHeader; |
| 17 | + |
14 | 18 | class Editor |
15 | 19 | { |
16 | 20 | LinkedList<Chip> chipList; |
@@ -97,6 +101,7 @@ public void saveChipToFile(Chip c) { |
97 | 101 | connection.put("to", to); |
98 | 102 |
|
99 | 103 | connections.add(connection); |
| 104 | + |
100 | 105 | } |
101 | 106 | } |
102 | 107 |
|
@@ -331,6 +336,26 @@ public void printTruthTable(Chip c) { |
331 | 336 | truthTable[i][c.iPins.size() + j] = c.oPins.get(j).activated; |
332 | 337 | } |
333 | 338 | } |
| 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); |
334 | 359 | } |
335 | 360 |
|
336 | 361 | public void pinOut(Chip c) { |
|
0 commit comments