Skip to content

fixed the sales price problem #24

Merged
merged 2 commits into from
Feb 16, 2026
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}


}
15 changes: 8 additions & 7 deletions src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Stock.java
Original file line number Diff line number Diff line change
@@ -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<BigDecimal> prices;
private List<BigDecimal> prices = new ArrayList<>();

public Stock(String symbol, String company, List<BigDecimal> prices) {
public Stock(String symbol, String company, BigDecimal salesPrice) {
this.symbol = symbol;
this.company = company;
this.prices = prices;
prices.add(salesPrice);
}

public String getSymbol() {
Expand All @@ -22,11 +23,11 @@ public String getCompany() {
return company;
}

public List<BigDecimal> getSalesPrices() {
return prices;
public BigDecimal getSalesPrice() {
return prices.getLast();
}

public void addNewSalesPrices(List<BigDecimal> prices) {
this.prices = prices;
public void addNewSalesPrices(BigDecimal salesPrice) {
prices.add(salesPrice);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction;

import java.math.BigDecimal;

public class Purchase {
}