From 570e37cb6795abd9d91bf1c5a8fb097fbc0725f4 Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 5 Mar 2026 17:43:49 +0100 Subject: [PATCH] Adding player class --- src/main/java/temppackage/Player.java | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/main/java/temppackage/Player.java b/src/main/java/temppackage/Player.java index 4f2b6d6..1e12a80 100644 --- a/src/main/java/temppackage/Player.java +++ b/src/main/java/temppackage/Player.java @@ -8,4 +8,36 @@ public class Player { private BigDecimal money; private Portfolio portfolio; private TransactionArchive transactionArchive; + + public Player(String name, BigDecimal startingMoney) { + this.name = name; + this.startingMoney = startingMoney; + this.money = startingMoney; + this.portfolio = new Portfolio(); + this.transactionArchive = new TransactionArchive(); + } + + public void addMoney(BigDecimal amount) { + this.money = this.money.add(amount); + } + + public void withdrawMoney(BigDecimal amount) { + this.money = this.money.subtract(amount); + } + + public String getName() { + return this.name; + } + + public BigDecimal getMoney() { + return this.money; + } + + public Portfolio getPortfolio() { + return this.portfolio; + } + + public TransactionArchive getTransactionArchive() { + return this.transactionArchive; + } }