Skip to content

Commit

Permalink
Added new methods to Exchange class
Browse files Browse the repository at this point in the history
  • Loading branch information
elisab3 committed Mar 24, 2026
1 parent 2459139 commit d2c472a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/Exchange.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ public void advance() {
}
}

public List<Stock> getGainers(int limit) { // viser "vinnerne"
return stockMap.values().stream()
.sorted((stock1, stock2) -> stock2.getLatestPriceChange().compareTo(stock1.getLatestPriceChange()))
.limit(limit)
.toList();
}


public List<Stock> getLosers(int limit) { // viser "taperne"
return stockMap.values().stream()
.sorted((stock1, stock2) -> stock1.getLatestPriceChange().compareTo(stock2.getLatestPriceChange()))
.limit(limit)
.toList();
}
}
Binary file modified target/classes/Exchange.class
Binary file not shown.

0 comments on commit d2c472a

Please sign in to comment.