Skip to content

Documentation #65

Merged
merged 23 commits into from
May 25, 2026
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6ff4a15
chore: JavaDocs for model.
pawelsa May 24, 2026
a00e72e
chore: JavaDocs for UI structures.
pawelsa May 24, 2026
5256d3a
chore: JavaDocs for views.
pawelsa May 24, 2026
4a74ab4
chore: Refactor tests for all model classes.
May 25, 2026
ca21db4
chore: Delete tests which are user interaction centered.
May 25, 2026
50a7131
chore: Delete test resources.
May 25, 2026
5c86b15
refactor: Model classes based on test results.
May 25, 2026
a5166a7
chore: Restore method lines for checking if divisor is null (Empty po…
May 25, 2026
851c6c9
feat: Add clickable share to go to stock.
May 25, 2026
4fa891f
feat(Exchange): Set gainers/losers to percent change instead of chang…
May 25, 2026
e9196e8
feat(SceneFactory): Optional marking for ExchangeView
May 25, 2026
f1eebb7
feat: Add Home button
May 25, 2026
853f9a9
feat(Exchange MVC): Sort by if stock has new news
May 25, 2026
3d4fc0d
feat: Create wrappers for view initialization
pawelsa May 25, 2026
d7d92fd
feat(Stock MVC): 'Sell in portfolio' button functionality
pawelsa May 25, 2026
e153764
refactor: Apply SceneFactory wrappers
pawelsa May 25, 2026
a54e919
feat: Style and layout enchancements
pawelsa May 25, 2026
aa8af0a
chore: Delete unnecesary icons, remake to white
pawelsa May 25, 2026
e4b98e9
feat: Remake searchbar to reactive on input
pawelsa May 25, 2026
faa0905
feat: Add PlayerStatusEnum with 3 new statuses.
pawelsa May 25, 2026
e2a5eb2
feat: Styling changes
pawelsa May 25, 2026
20a8e50
feat: Make player status a observable field in UserSession
pawelsa May 25, 2026
bfb8f9b
refactor: Naming
pawelsa May 25, 2026
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
6 changes: 6 additions & 0 deletions src/main/java/edu/ntnu/idi/idatt/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ static void main() {
Application.launch(Millions.class);
}

/**
* Class for JavaFX startup.
*/
public static final class Millions extends Application {

/**
* JavaFX entry point.
*/
@Override
public void start(Stage stage) {
stage.setWidth(1440);
Expand Down
33 changes: 21 additions & 12 deletions src/main/java/edu/ntnu/idi/idatt/model/Exchange.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,28 @@ public Exchange(String name, List<Stock> stocks) {
}

/**
*
* Getters
*
* @return - their corresponding variables.
* Getter for name.
*
* @return String;
*/

public String getName() {
return name;
}

/**
* Getter for week.
*
* @return int;
*/
public int getWeek() {
return week;
}

/**
* Getter for all stocks.
*
* @return List of Stocks.
*/
public List<Stock> getStocks() {
return stockMap.values().stream().toList();
}
Expand Down Expand Up @@ -106,16 +114,16 @@ public List<Stock> findStocks(String searchTerm) {
*
* <p>
* Returns the stocks that have done it the best
* in the latest week.
* (percent change) in the latest week.
* </p>
*
* @param limit - Amount of stocks to be returned.
* @return A list of stocks sorted in declining order.
*/
public List<Stock> getGainers(int limit) {
return stockMap.values().stream()
.filter(stock -> stock.getLatestPriceChange().compareTo(BigDecimal.ZERO) > 0)
.sorted(Comparator.comparing(Stock::getLatestPriceChange).reversed())
.filter(stock -> stock.getLatestPriceChangePercent().compareTo(BigDecimal.ZERO) > 0)
.sorted(Comparator.comparing(Stock::getLatestPriceChangePercent).reversed())
.limit(limit)
.toList();
}
Expand All @@ -125,16 +133,16 @@ public List<Stock> getGainers(int limit) {
*
* <p>
* Returns the stocks that have done it the worst
* in value in the latest week.
* in percent change in the latest week.
* </p>
*
* @param limit - Amount of stocks to be returned.
* @return A list of stocks sorted in inclining order.
* @return A list of stocks sorted in ascending order.
*/
public List<Stock> getLosers(int limit) {
return stockMap.values().stream()
.filter(stock -> stock.getLatestPriceChange().compareTo(BigDecimal.ZERO) < 0)
.sorted(Comparator.comparing(Stock::getLatestPriceChange))
.filter(stock -> stock.getLatestPriceChangePercent().compareTo(BigDecimal.ZERO) < 0)
.sorted(Comparator.comparing(Stock::getLatestPriceChangePercent))
.limit(limit)
.toList();
}
Expand Down Expand Up @@ -189,6 +197,7 @@ public Transaction sell(Share share, Player player) {
*
* <p>
* Adds a new price to each of the stock array.
* Progresses week counter.
* </p>
*
* @see Stock
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/edu/ntnu/idi/idatt/model/enums/NewspaperEnum.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package edu.ntnu.idi.idatt.model.enums;

/**
* Newspaper enum.
*
* <p>
* Creates static events that can occur within Newspaper.
* </p>
*
* @see Newspaper
*/
public enum NewspaperEnum {
NEW_PRODUCT(
"New product announced!",
Expand Down Expand Up @@ -83,25 +92,48 @@ public enum NewspaperEnum {
private final double trend;
private final double volatility; // How violently the price moves factor

/**
* Constructor for NewspaperEnum
*/
NewspaperEnum(String title, String description, double trend, double volatility) {
this.title = title;
this.description = description;
this.trend = trend;
this.volatility = volatility;
}

/**
* Getter for title
*
* @return String;
*/
public String getTitle() {
return title;
}

/**
* Getter for description
*
* @return String;
*/
public String getDescription() {
return description;
}

/**
* Getter for trend
*
* @return double;
*/
public double getTrend() {
return trend;
}

/**
* Getter for volatility
*
* @return double;
*/
public double getVolatility() {
return volatility;
}
Expand Down
64 changes: 64 additions & 0 deletions src/main/java/edu/ntnu/idi/idatt/model/enums/PlayerStatusEnum.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package edu.ntnu.idi.idatt.model.enums;

import java.math.BigDecimal;

import edu.ntnu.idi.idatt.model.player.Player;

/**
* Enum class that holds the different player statuses.
*
* @see Player
*/
public enum PlayerStatusEnum {
ROARING_KITTY("Roaring Kitty", 50, new BigDecimal("8")),
PAPER_HANDS("Paper Hands", 100, new BigDecimal("2")),
SPECULATOR("Speculator", 20, new BigDecimal("2")),
DIAMOND_HANDS("Diamond Hands", 10, new BigDecimal("3")),
INVESTOR("Investor", 10, new BigDecimal("1.2")),
NOVICE("Novice", 0, BigDecimal.ZERO);

private final String title;
private final int tradingWeeks;
private final BigDecimal ratio;

/**
* Constructor for PlayerStatusEnum
*
* @param title - Status name
* @param tradingWeeks - How many weeks in trading to reach status.
* @param ratio - NetWorth/starting money
*/
PlayerStatusEnum(String title, int tradingWeeks, BigDecimal ratio) {
this.title = title;
this.tradingWeeks = tradingWeeks;
this.ratio = ratio;
}

/**
* Getter for title.
*
* @return String;
*/
public String getTitle() {
return title;
}

/**
* Getter for trading weeks.
*
* @return int;
*/
public int getTradingWeeks() {
return tradingWeeks;
}

/**
* Getter for ratio.
*
* @return BigDecimal.
*/
public BigDecimal getRatio() {
return ratio;
}

}
38 changes: 38 additions & 0 deletions src/main/java/edu/ntnu/idi/idatt/model/market/Newspaper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,32 @@

import edu.ntnu.idi.idatt.model.enums.NewspaperEnum;

/**
* Newspaper class
*
* <p>
* This class is used together with Stock,
* to provide a event-based context for the
* prices.
* </p>
*
* @see Stock
*/
public class Newspaper {

ArrayList<NewspaperEnum> news = new ArrayList<>(List.of(NewspaperEnum.NONE_EVENT));
private static double chance = 0.05; // In percent

/**
* Method for creating news.
*
* <p>
* Creates news and adds them to the
* news ArrayList.
* </p>
*
* @return NewspaperEnum of NONE or random event.
*/
public NewspaperEnum makeNews() {
Random r = new Random();
double roll = r.nextDouble();
Expand All @@ -27,14 +48,31 @@ public NewspaperEnum makeNews() {
return event;
}

/**
* Method for checking if Newspaper has new news.
*
* @return true/false depending if a real event exists.
*/
public boolean hasNewNews() {
return news.getLast().equals(NewspaperEnum.NONE_EVENT) ? false : true;
}

/**
* Getter for news arraylist.
*/
public ArrayList<NewspaperEnum> getNews() {
return news;
}

/**
* Method for converting the arraylist to formatted strings.
*
* <p>
* Converts NewspaperEnum to fitting String format.
* </p>
*
* @return List of strings.
*/
public List<String> getNewsStrings() {

ArrayList<String> strings = new ArrayList<>();
Expand Down
Loading
Loading