Skip to content

Commit

Permalink
Merge pull request #22 from einaskoi/einar/portfolio
Browse files Browse the repository at this point in the history
add initial portfolio implementation
  • Loading branch information
peretr authored Feb 16, 2026
2 parents 99586f2 + 9ead533 commit 714ab0b
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Portfolio.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,50 @@
package edu.ntnu.idi.idatt2003.gruppe42.Model;

import java.util.ArrayList;
import java.util.List;

/**
* Portfolio represents a collection of {@link Share} objects owned by a {@link Player}.
* The class includes methods for adding, removing and getting shares from the portfolio.
*/
public class Portfolio {
private List<Share> shares;

/**
* The constructor of the {@link Portfolio} class.
*/
public Portfolio() {
this.shares = new ArrayList<>();
}

/**
* Method for adding a share to a portfolio.
* @param share represents the share to be added to the portfolio.
* @return true or false based on if the operation was successful or not.
*/
public boolean addShare(Share share) {
return true;
}

/**
* Method for removing a share to a portfolio.
* @param share represents the share to be removed from the portfolio.
* @return true or false based on if the operation was successful or not.
*/
public boolean removeShare(Share share) {
return false;
}

public List<Share> getShares() {
return this.shares;
}

/**
* Method for checking if a portfolio contains a given share.
* @param share represents the share to be checked.
* @return true or false based on if the share was found or not.
*/
public boolean contains(Share share) {
return true;
}
}

0 comments on commit 714ab0b

Please sign in to comment.