Skip to content

Commit

Permalink
Player class javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
EspenTinius committed Feb 19, 2026
1 parent 1576662 commit 4077306
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ public class Player {
private final Portfolio portfolio;
private final TransactionArchive transactionArchive;

/**
* Creates a new player with a given name and starting capital.
*
* @param name the name of the player
* @param startingMoney the starting amount of money
*/
public Player(String name, BigDecimal startingMoney) {
this.name = name;
this.startingMoney = startingMoney;
Expand All @@ -19,26 +25,56 @@ public Player(String name, BigDecimal startingMoney) {
this.transactionArchive = new TransactionArchive();
}

/**
* Returns the name of the player.
*
* @return the player's name
*/
public String getName() {
return name;
}

/**
* Returns the players current balance.
*
* @return the current amount of money
*/
public BigDecimal getMoney() {
return money;
}

/**
* Adds money to the players balance.
*
* @param amount the amount to add
*/
public void addMoney(BigDecimal amount) {
money = money.add(amount);
}

/**
* Withdraws money from the players balance.
*
* @param amount the amount to withdraw
*/
public void withdrawMoney(BigDecimal amount) {
money = money.subtract(amount);
}

/**
* Returns the players portfolio.
*
* @return the portfolio
*/
public Portfolio getPortfolio() {
return portfolio;
}

/**
* Returns the players transaction archive.
*
* @return the transaction archive
*/
public TransactionArchive getTransactionArchive() {
return transactionArchive;
}
Expand Down

0 comments on commit 4077306

Please sign in to comment.