From 9ead5331c3f48ad3eebef01a666719003eb34d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Einar=20Sk=C3=B8ien?= Date: Mon, 16 Feb 2026 10:52:54 +0100 Subject: [PATCH] add initial portfolio implementation --- .../idatt2003/gruppe42/Model/Portfolio.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Portfolio.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Portfolio.java index 89141ef..fcb26a0 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Portfolio.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Portfolio.java @@ -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 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 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; + } }