From 7c28b72f15f1dba9dd7a02ddb53417216318c293 Mon Sep 17 00:00:00 2001 From: Per Eric Trapnes Date: Mon, 16 Feb 2026 11:24:22 +0100 Subject: [PATCH] inital player commit --- .../ntnu/idi/idatt2003/gruppe42/Millions.java | 3 +- .../idi/idatt2003/gruppe42/Model/Player.java | 60 +++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Millions.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Millions.java index 810c9bc..d55ae34 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Millions.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Millions.java @@ -3,5 +3,6 @@ public class Millions { public static void main(String[] args) { System.out.println("PLEASE WORK GIT"); - } + } } + diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Player.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Player.java index 64d9748..b5dff97 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Player.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Player.java @@ -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); + } + + }