Skip to content

Commit

Permalink
🐛 Fixed minor bugs and typos
Browse files Browse the repository at this point in the history
  • Loading branch information
pitzzahh committed Jan 15, 2024
1 parent 64faa9f commit b980d91
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/main/java/me/araopj/cscreen/components/CTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

import me.araopj.cscreen.classes.Position;
import me.araopj.cscreen.classes.Utilities;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.io.PrintStream;
import static java.lang.System.out;
import java.util.*;

/**
Expand Down Expand Up @@ -118,16 +115,11 @@ void init() {
* Displays the table on the screen.
*/
public void display() {
try {
generateScreen();
PrintStream out = new PrintStream(System.out, true, StandardCharsets.UTF_8.name());
Arrays.stream(screen).forEach(value -> {
IntStream.range(0, screen[0].length).forEachOrdered(j -> out.print(value[j]));
out.println();
});
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
generateScreen();
Arrays.stream(screen).forEach(value -> {
IntStream.range(0, screen[0].length).forEachOrdered(j -> out.print(value[j]));
out.println();
});
}

/**
Expand Down Expand Up @@ -359,6 +351,16 @@ public void setColumnAlignment(int columnIndex, Position position) {
alignments.put(columnIndex, position);
}

/**
* Sets the alignment for all columns in the table.
* @param position The alignment position for all the columns.
*/
public void setColumnAlignment(Position position) {
for (int i = 0; i < this.columnHeader.length; i++) {
alignments.put(i, position);
}
}

/**
* Calculates the total sum of numeric values in a specific column.
*
Expand All @@ -376,7 +378,7 @@ public int getTotal(int columnIndex) {
* @param columnIndex The index of the column.
* @return The total sum of floating-point values in the specified column.
*/
public double getFloatTotal(int columnIndex) {
public double getDoubleTotal(int columnIndex) {
return list2D.stream()
.filter(i -> i.stream().filter(Utilities::isNumeric).isParallel()).mapToDouble(row -> columnIndex).sum();
}
Expand Down

0 comments on commit b980d91

Please sign in to comment.