Skip to content

Commit

Permalink
Update Exchange
Browse files Browse the repository at this point in the history
Added JavaDoc.
  • Loading branch information
roaraf committed Mar 27, 2026
1 parent 8e0d87c commit da2fde9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions millions/src/main/java/no/ntnu/gruppe53/Exchange.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ public void advance() {
}
}

/**
* Lists the given amount of stocks sorted by highest increase in sales price since last week.
* @param entries amount of stocks to be shown in list
* @return a descending list of stocks with the highest price increase since last week
* @throws IllegalArgumentException if number of entries in list is negative
*/
public List<Stock> getGainers(int entries) {
if (entries < 0) {
throw new IllegalArgumentException("Amount of entries in list cannot be negative.");
Expand All @@ -159,6 +165,14 @@ public List<Stock> getGainers(int entries) {
.collect(Collectors.toList());
}

/**
* Lists the given amount of stocks sorted by the stocks with the lowest price increase (or
* highest price decrease)
* @param entries amount of stocks to be shown in the list
* @return a descending list of stocks with the highest price decrease or
* lowest price increase
* @throws IllegalArgumentException if number of entries in list is negative
*/
public List<Stock> getLosers(int entries) {
if (entries < 0) {
throw new IllegalArgumentException("Amount of entries in list cannot be negative.");
Expand Down

0 comments on commit da2fde9

Please sign in to comment.