-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from einaskoi/per/player
inital player commit
- Loading branch information
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
60
src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Player.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
|
|
||
|
|
||
| } |