Skip to content

Commit

Permalink
implement logic in Portfolio class
Browse files Browse the repository at this point in the history
  • Loading branch information
einaskoi committed Feb 23, 2026
1 parent 8067564 commit 0bafdcb
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Portfolio.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ public Portfolio() {
* @return true or false based on if the operation was successful or not.
*/
public boolean addShare(Share share) {
return true;
if (share == null) {
return false;
} else {
return shares.add(share);
}
}

/**
Expand All @@ -32,7 +36,11 @@ public boolean addShare(Share share) {
* @return true or false based on if the operation was successful or not.
*/
public boolean removeShare(Share share) {
return false;
if (share == null || !shares.contains(share)) {
return false;
} else {
return shares.remove(share);
}
}

public List<Share> getShares() {
Expand All @@ -45,6 +53,6 @@ public List<Share> getShares() {
* @return true or false based on if the share was found or not.
*/
public boolean contains(Share share) {
return true;
return share != null && shares.contains(share);
}
}

0 comments on commit 0bafdcb

Please sign in to comment.