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); + } + + } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Stock.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Stock.java index b818084..084ac3a 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Stock.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Stock.java @@ -1,17 +1,18 @@ package edu.ntnu.idi.idatt2003.gruppe42.Model; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.List; public class Stock { private final String symbol; private final String company; - private List prices; + private List prices = new ArrayList<>(); - public Stock(String symbol, String company, List prices) { + public Stock(String symbol, String company, BigDecimal salesPrice) { this.symbol = symbol; this.company = company; - this.prices = prices; + prices.add(salesPrice); } public String getSymbol() { @@ -22,11 +23,11 @@ public String getCompany() { return company; } - public List getSalesPrices() { - return prices; + public BigDecimal getSalesPrice() { + return prices.getLast(); } - public void addNewSalesPrices(List prices) { - this.prices = prices; + public void addNewSalesPrices(BigDecimal salesPrice) { + prices.add(salesPrice); } } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Purchase.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Purchase.java index 99e0a1c..d7c5d36 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Purchase.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Purchase.java @@ -1,4 +1,6 @@ package edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction; +import java.math.BigDecimal; + public class Purchase { }