Skip to content

Commit

Permalink
inital player commit
Browse files Browse the repository at this point in the history
  • Loading branch information
peretr committed Feb 16, 2026
1 parent 99586f2 commit 7c28b72
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Millions.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
public class Millions {
public static void main(String[] args) {
System.out.println("PLEASE WORK GIT");
}
}
}

60 changes: 60 additions & 0 deletions src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Player.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,64 @@
package edu.ntnu.idi.idatt2003.gruppe42.Model;

import edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction.TransactionArchive;
import java.math.BigDecimal;

/**
* Player represents the user, the money they own, and their portfolio.
* The class includes methods for adding and withdrawing money from the players portfolio.
*/
public class Player {
private final String name;
private final BigDecimal startingMoney;
private BigDecimal money;
private Portfolio portfolio;
private TransactionArchive transactionArchive;

/**
*
* @param name
* @param startingMoney
*/
public Player(String name, BigDecimal startingMoney) {
this.name = name;
this.startingMoney = startingMoney;
this.money = startingMoney;
this.portfolio = new Portfolio();
this.transactionArchive = new TransactionArchive();

}

public String getName() {
return name;
}

public Portfolio getPortfolio() {
return portfolio;
}

public TransactionArchive getTransactionArchive() {
return transactionArchive;
}

public BigDecimal getMoney() {
return money;
}

/**
*
* @param amount is the amount that will be added to players account.
*/
public void addMoney(BigDecimal amount) {
money = money.add(amount);
}

/**
*
* @param amount is the amount that will be withdrawn from players account.
*/
public void withdrawMoney(BigDecimal amount) {
money = money.subtract(amount);
}


}

0 comments on commit 7c28b72

Please sign in to comment.