Skip to content

add initial portfolio implementation #22

Merged
merged 1 commit into from
Feb 16, 2026
Merged
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
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;
}
}