Skip to content

Commit

Permalink
refactor(..Component): Use toString method
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelsa committed May 14, 2026
1 parent 9c2f885 commit 848b98b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public StockComponent(Stock stock) {

this.setStyle("-fx-background-color: #404950;");

Label title = new Label(String.format("%s (%s)", stock.getCompany(), stock.getSymbol()));
Label title = new Label(stock.toString());

Label latestText = new Label("Latest");
Label latestValue = new Label(String.format("%.2f USD", stock.getSalesPrice()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,23 @@ public class TransactionComponent extends VBox {
public TransactionComponent(Transaction transaction) {

Stock stock = transaction.getShare().getStock();
TransactionCalculator calculator = transaction.getCalculator();

Label title;
Label name = new Label(stock.getCompany() + " (" + stock.getSymbol() + ")");
Label name = new Label(stock.toString());
Label totalValue;
Label taxComissionValue;
Label grossValue;
Label amountOfShares;
Label saleProfit;

TransactionCalculator calculator = transaction.getCalculator();
totalValue = new Label(String.format("Total: %.2f USD", calculator.calculateTotal()));

taxComissionValue = new Label(String.format(
"Tax & Comission: %.2f USD", calculator.calculateTax().add(calculator.calculateCommision())));

grossValue = new Label(String.format("Gross: %.2f USD", calculator.calculateGross()));

amountOfShares = new Label(
String.format("Shares: %.2f [%s]", transaction.getShare().getQuantity(), stock.getSymbol()));

Expand Down

0 comments on commit 848b98b

Please sign in to comment.