-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This will not work until other classes have been merged
- Loading branch information
EspenTinius
committed
Feb 19, 2026
1 parent
f3e7f30
commit 1576662
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import java.util.Objects; | ||
|
|
||
| public class Player { | ||
|
|
||
| private final String name; | ||
| private final BigDecimal startingMoney; | ||
| private BigDecimal money; | ||
| private final Portfolio portfolio; | ||
| private final TransactionArchive transactionArchive; | ||
|
|
||
| public Player(String name, BigDecimal startingMoney) { | ||
| this.name = name; | ||
| this.startingMoney = startingMoney; | ||
| this.money = this.startingMoney; | ||
| this.portfolio = new Portfolio(); | ||
| this.transactionArchive = new TransactionArchive(); | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public BigDecimal getMoney() { | ||
| return money; | ||
| } | ||
|
|
||
| public void addMoney(BigDecimal amount) { | ||
| money = money.add(amount); | ||
| } | ||
|
|
||
| public void withdrawMoney(BigDecimal amount) { | ||
| money = money.subtract(amount); | ||
| } | ||
|
|
||
| public Portfolio getPortfolio() { | ||
| return portfolio; | ||
| } | ||
|
|
||
| public TransactionArchive getTransactionArchive() { | ||
| return transactionArchive; | ||
| } | ||
| } |