Skip to content

add player getNetworthTest #63

Merged
merged 1 commit into from
Apr 9, 2026
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class PurchaseCalculatorTest {

@BeforeEach
void setUp() {
// Setup test data
purchasePrice = new BigDecimal("100");
quantity = new BigDecimal("10");
Stock stock = new Stock("AAPL", "Apple Inc.", new BigDecimal("150"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class SaleCalculatorTest {

@BeforeEach
void setUp() {
// Setup test data
purchasePrice = new BigDecimal("100");
salesPrice = new BigDecimal("150");
quantity = new BigDecimal("10");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,14 @@ void withdrawExactAmountTest() {
player.withdrawMoney(new BigDecimal("10000"));
assertEquals(BigDecimal.ZERO, player.getMoney());
}

@Test
void getNetworthTest() {

// Starting with 10000 money and adding 5000 moneys worth of AAPL then calculating the networth
// with commissions taken account of will result in this:
// 10000 + 5000 - (5000 * 0.01) = 14950
player.getPortfolio().addShare(new Share(new Stock("AAPL", "Apple Inc.", new BigDecimal("5000")), new BigDecimal("1"), new BigDecimal("5000")));
assertEquals(new BigDecimal("14950"), player.getNetWorth());
}
}